Terraform: AWS OpsWorks resources cannot be imported from any region other than us-east-1

Created on 3 Nov 2016  ยท  3Comments  ยท  Source: hashicorp/terraform

This issue arrises from a question on the mailing list (see here). Here, it was confirmed that this is a bug, thus this issue.

The problem is that OpsWorks resources cannot be imported from anywhere other than us-east-1. The reason for this is that the OpsWorks client is hard-coded to connect to us-east-1 here. The assumption that OpsWorks is only supported in us-east-1 was true until recently. It is now incorrect.

One possible solution is to remove the restriction of the OpsWorks client to us-east-1.

Terraform Version

Terraform v0.7.8

Affected Resource(s)

I have confirmed that the issue affects:

  • aws_opsworks_stack
  • aws_opsworks_custom_layer

However, it's likely that this affects all OpsWorks resources.

Terraform Configuration Files

None necessary

Debug Output

https://gist.github.com/blooshirt/269a2152eac887b2e66f11a787211926

Expected Behavior

Terraform should import the OpsWorks stack with the given ID.

Actual Behavior

Terraform fails with an error indicating that the stack cannot be found.

Steps to Reproduce

  1. Create test stack on AWS in eu-west-1:
    aws opsworks create-stack \ --name terraform_test \ --vpc-id <vpc_id> \ --service-role-arn <service_role_arn> \ --default-instance-profile-arn <ec2_role_instance_profile> \ --stack-region eu-west-1 \ --default-subnet-id <subnet_id> \ --configuration-manager Name=Chef,Version=12
  2. Import stack with Terraform:
    TF_LOG=DEBUG terraform8 import aws_opsworks_stack.terraform_test <stack_id>
  3. Input eu-west-1 when prompted for region.
  4. Observe failure
bug provideaws

Most helpful comment

I've noticed that new Stacks always get created in the us-east-1 region; I suspect fixing this will fix that too.

The stack-region parameter of http://docs.aws.amazon.com/cli/latest/reference/opsworks/create-stack.html

All 3 comments

I've noticed that new Stacks always get created in the us-east-1 region; I suspect fixing this will fix that too.

The stack-region parameter of http://docs.aws.amazon.com/cli/latest/reference/opsworks/create-stack.html

I edited the file mentioned in blooshirt's reporting of the bug and compiled in debug mode. I was able to successfully run terraform import was_opsworks_stack for zone us-west-1.

Unfortunately when I tried to run the tests they failed, so I couldn't issue a pull request.

What I did:
this is line 285
client.opsworksconn = opsworks.New(usEast1Sess)

I changed it to
client.opsworksconn = opsworks.New(less)

So it uses the region passed in by the command line

I don't know go, so if I get ambitious I may try and fix the tests and issue a pull request.

Thanks,

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelsawicz picture pawelsawicz  ยท  3Comments

carl-youngblood picture carl-youngblood  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

zeninfinity picture zeninfinity  ยท  3Comments

larstobi picture larstobi  ยท  3Comments