hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.11k forks source link

unable to add aws_db_instance_role_association #11745

Closed tormodmacleod closed 4 years ago

tormodmacleod commented 4 years ago

Community Note

Terraform Version

$ terraform -v
Terraform v0.12.10

Affected Resource(s)

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.46.0...
- Downloading plugin for provider "template" (hashicorp/template) 2.1.2...
- Downloading plugin for provider "null" (hashicorp/null) 2.1.2...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.aws: version = "~> 2.46"
* provider.null: version = "~> 2.1"
* provider.template: version = "~> 2.1"

Terraform Configuration Files

resource "aws_db_instance_role_association" "example" {
  db_instance_identifier = "DATABASE"
  feature_name           = "S3_INTEGRATION"
  role_arn               = "arn:aws:iam::123412341234:role/rds-s3-transfer-integration-role"
}

Debug Output

2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: panic: runtime error: invalid memory address or nil pointer dereference
2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x4217446]
2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: 
2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: goroutine 124 [running]:
2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.waitForRdsDbInstanceRoleAssociation.func1(0xc000065f50, 0xc000065e78, 0x2, 0x1, 0x1, 0x5f513b0)
2020-01-23T23:30:02.830Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4:      /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_db_instance_role_association.go:210 +0x66
2020-01-23T23:30:02.831Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState.func1(0xc0009c4c60, 0xc0003c7d50, 0xc0009cadc0, 0xc000ca27e0, 0xc000c45298, 0xc000c45290)
2020-01-23T23:30:02.831Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4:      /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.5.0/helper/resource/state.go:103 +0x29d
2020-01-23T23:30:02.831Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4: created by github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState
2020-01-23T23:30:02.831Z [DEBUG] plugin.terraform-provider-aws_v2.46.0_x4:      /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.5.0/helper/resource/state.go:80 +0x1bf
2020-01-23T23:30:02.838Z [DEBUG] plugin: plugin process exited: path=/tmp/tmp.UbRRJJH4qc-terraform-bbragile/tf/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.46.0_x4 pid=166296 error="exit status 2"
2020/01/23 23:30:02 [DEBUG] aws_db_instance_role_association.example: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing

Panic Output

Expected Behavior

Terraform will perform the following actions:

  # aws_db_instance_role_association.example will be created
  + resource "aws_db_instance_role_association" "example" {
      + db_instance_identifier = "DATABASE"
      + feature_name           = "S3_INTEGRATION"
      + id                     = (known after apply)
      + role_arn               = "arn:aws:iam::123412341234:role/rds-s3-transfer-integration-role"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Actual Behavior

Error: error associating RDS DB Instance (DATABASE) IAM Role (arn:aws:iam::123412341234:role/rds-s3-transfer-integration-role): DBInstanceRoleAlreadyExists: The arn:aws:iam::123412341234:role/rds-s3-transfer-integration-role IAM role or S3_INTEGRATION feature is already associated with the DATABASE DB instance. Check the name and try again.
        status code: 400, request id: d6a3d6b5-aa4c-46a5-9747-da5d7b09fd93

  on rds.tf line 198, in resource "aws_db_instance_role_association" "example":
 198: resource "aws_db_instance_role_association" "example" {

2020-01-23T23:12:19.510Z [DEBUG] plugin: plugin process exited: path=/tmp/tmp.Z5fJUKbCoo-terraform-bbragile/tf/aws/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.46.0_x4 pid=158745
2020-01-23T23:12:19.510Z [DEBUG] plugin: plugin exited

Steps to Reproduce

  1. terraform apply

Important Factoids

References

tormodmacleod commented 4 years ago

i don't think this is a result of some silly mistake i'm making but apologies in advance if it is. i hope i've provided all the necessary information but please do let me know if something's missing

userhas404d commented 4 years ago

seeing similar behavior with the current AWS provider (2.60.0):

2020-05-06T19:43:50.132-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: 2020/05/06 19:43:50 [DEBUG] RDS DB Instance (arn:aws:rds:us-east-1:123456789123:db:test) IAM Role associating: arn:aws:iam::123456789123:role/test-612qbmsl-rds
2020-05-06T19:43:50.273-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: 2020/05/06 19:43:50 [DEBUG] Waiting for RDS DB Instance (arn:aws:rds:us-east-1:123456789123:db:test) IAM Role association: arn:aws:iam::123456789123:role/test-612qbmsl-rds
2020-05-06T19:43:50.273-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: 2020/05/06 19:43:50 [DEBUG] Waiting for state to become: [ACTIVE]
2020/05/06 19:43:52 [TRACE] dag/walk: vertex "root" is waiting for "provider.aws (close)"
2020/05/06 19:43:55 [TRACE] dag/walk: vertex "provider.aws (close)" is waiting for "aws_db_instance_role_association.this"
2020/05/06 19:43:55 [TRACE] dag/walk: vertex "meta.count-boundary (EachMode fixup)" is waiting for "aws_db_instance_role_association.this"
2020-05-06T19:43:55.274-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: 2020/05/06 19:43:55 [DEBUG] Describing RDS DB Instance: {
2020-05-06T19:43:55.274-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4:   DBInstanceIdentifier: "arn:aws:rds:us-east-1:123456789123:db:test"
2020-05-06T19:43:55.274-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: }
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: panic: runtime error: invalid memory address or nil pointer dereference
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x424a8d6]
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: 
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: goroutine 170 [running]:
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.waitForRdsDbInstanceRoleAssociation.func1(0xc000bf9f50, 0xc000bf9e78, 0x2, 0x1, 0xc000bf9f01, 0x42ca0a)
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_db_instance_role_association.go:210 +0x66
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState.func1(0xc0005ffa40, 0xc000210540, 0xc0000e0b40, 0xc0000e2ae0, 0xc000d75d78, 0xc000d75d70)
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/resource/state.go:103 +0x29d
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4: created by github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState
2020-05-06T19:43:55.430-0400 [DEBUG] plugin.terraform-provider-aws_v2.60.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/resource/state.go:80 +0x1bf
2020-05-06T19:43:55.431-0400 [DEBUG] plugin: plugin process exited: path=/home/tcmulder/rds-testing/.terragrunt-cache/vs3-yD2YSBV1lP4J2dFgOpNU62Q/00ZR20X4VzyFR6aEyQ22UqCUu5k/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.60.0_x4 pid=14233 error="exit status 2"
bflad commented 4 years ago

The fix for this has been merged and will release with version 2.69.0 of the Terraform AWS Provider, likely later today. πŸ‘

ghost commented 4 years ago

This has been released in version 2.69.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

ghost commented 4 years ago

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!