Reputation: 917
I've been upgrading my terraform config from 0.11 to 0.13 as well as removing a module from the state file (using terraform state rm module.mymodulename).
After removing the resource above I am now running into a whole host of errors when running a plan command. Now I'm not too sure if it's related to me removing the module or if it's linked to the upgrade. I can see that the placement_strategy attribute has been deprecated for aws_ecs_service and I'm a bit stumped on how to safely remove it from the state file.
Placement_strategy isn't something that I've defined in the resource and is just a default from the earlier version.
Anyone any advice on how to tackle the issues below? I need to get this back up and running as it's for our development environment. I'm leaning towards removing the resource "aws_ecs_service" "myappadmin-service" and importing it again.
terraform plan
Error: Invalid resource instance data in state
on ecs-instance-role.tf line 23:
23: resource "aws_iam_instance_profile" "ecs-instance-profile" {
Instance aws_iam_instance_profile.ecs-instance-profile data could not be
decoded from the state: unsupported attribute "roles".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Error: Invalid resource instance data in state
on modules\myappadmin\service.tf line 1:
1: resource "aws_ecs_service" "myappadmin-service" {
Instance module.myappadmin.aws_ecs_service.myappadmin-service data could not be
decoded from the state: unsupported attribute "placement_strategy".
Upvotes: 2
Views: 4689
Reputation: 74239
I'm not sure that this fully explains what you are seeing but one of these errors seems to be related to a change to aws_ecs_service
in AWS provider major version 2, which suggests that you're upgrading both Terraform and the AWS provider at the same time.
To make it easier to understand what's going on, I would suggest upgrading only one component at a time, so you can make any changes required for one upgrade before starting on the next upgrade, and so you won't have to correlate the release notes of various different components all at once.
Given what you've seen here, I would suggest the following ordering for your case:
While doing this in four steps rather than one might seem more arduous, it should mean that in each step you only need to worry about one set of release notes and you can focus any debugging you need to do on only one component.
Note that above I described upgrading one major version at a time, rather than skipping ahead. Terraform CLI in particular does not support upgrading directly from Terraform v0.11 to v0.13, because the automatic upgrade tool from Terraform v0.12 is no longer present in Terraform v0.13. The AWS provider could potentially be upgraded directly from v1 to v3, but to do that you'll need to consult the release notes of both versions at once.
It's possible that you might encounter these errors again at some point in the above process. If that is true, you'll be able to understand which change caused the problem, and potentially report the problem against that component (either the AWS provider or Terraform CLI, depending on what you've just upgraded.)
Upvotes: 3