Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_backup_selection: IAM Role cannot be assumed by AWS Backup #9297

Closed
bflad opened this issue Jul 10, 2019 · 5 comments · Fixed by #9298
Closed

resource/aws_backup_selection: IAM Role cannot be assumed by AWS Backup #9297

bflad opened this issue Jul 10, 2019 · 5 comments · Fixed by #9298
Labels
bug Addresses a defect in current functionality. service/backup Issues and PRs that pertain to the backup service.
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Jul 10, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.3
+ provider.aws v2.18.0

Affected Resource(s)

  • aws_backup_selection

Terraform Configuration Files

terraform {
  required_providers {
    aws = "2.18.0"
  }
}

provider "aws" {
  region = "us-east-2"
}

data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

resource "aws_iam_role" "test" {
  name               = "9269-testing"
  assume_role_policy = <<POLICY
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": ["sts:AssumeRole"],
      "Effect": "allow",
      "Principal": {
        "Service": ["backup.amazonaws.com"]
      }
    }
  ]
}
POLICY
}

resource "aws_iam_role_policy_attachment" "test" {
  policy_arn = "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup"
  role = "${aws_iam_role.test.name}"
}

resource "aws_backup_vault" "test" {
  name = "9269-testing"
}

resource "aws_backup_plan" "test" {
  name = "9269-testing"

  rule {
    rule_name = "test"
    target_vault_name = "${aws_backup_vault.test.name}"
    schedule = "cron(0 12 * * ? *)"
  }
}

resource "aws_backup_selection" "test" {
  iam_role_arn = "${aws_iam_role.test.arn}"
  name = "9269-testing"
  plan_id = "${aws_backup_plan.test.id}"

  resources = [
    "arn:aws:ec2:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:volume/*",
  ]
}

Expected Behavior

Successful AWS Backup Selection creation.

Actual Behavior

Error: error creating Backup Selection: InvalidParameterValueException: IAM Role arn:aws:iam::--OMITTED--:role/9269-testing cannot be assumed by AWS Backup

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

Retrying terraform apply works. Appears to be IAM eventual consistency issue.

@bflad bflad added bug Addresses a defect in current functionality. service/backup Issues and PRs that pertain to the backup service. labels Jul 10, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 10, 2019
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Jul 10, 2019
bflad added a commit that referenced this issue Jul 10, 2019
…tency error

Reference: #9297

Output from acceptance testing (failure present on master):

```
--- FAIL: TestAccAwsBackupSelection_withResources (12.00s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error creating Backup Selection: InvalidParameterValueException: Invalid ARN: arn:aws:elasticfilesystem:us-west-2:--OMITTED--:file-system/. Specified resource is not supported
        	status code: 400, request id: 2f845d03-51d3-48df-b853-46c077f85780

          on /var/folders/v0/_d108fkx1pbbg4_sh864_7740000gn/T/tf-test308326165/main.tf line 22:
          (source code not available)

--- PASS: TestAccAwsBackupSelection_disappears (17.20s)
--- PASS: TestAccAwsBackupSelection_basic (18.44s)
--- PASS: TestAccAwsBackupSelection_withTags (18.47s)
--- PASS: TestAccAwsBackupSelection_updateTag (28.73s)
```
@bflad
Copy link
Contributor Author

bflad commented Jul 10, 2019

Bug fix submitted: #9298

nywilken pushed a commit that referenced this issue Jul 10, 2019
* resource/aws_backup_selection: Retry creation for IAM eventual consistency error

Reference: #9297

Output from acceptance testing (failure present on master):

```
--- FAIL: TestAccAwsBackupSelection_withResources (12.00s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error creating Backup Selection: InvalidParameterValueException: Invalid ARN: arn:aws:elasticfilesystem:us-west-2:--OMITTED--:file-system/. Specified resource is not supported
        	status code: 400, request id: 2f845d03-51d3-48df-b853-46c077f85780

          on /var/folders/v0/_d108fkx1pbbg4_sh864_7740000gn/T/tf-test308326165/main.tf line 22:
          (source code not available)

--- PASS: TestAccAwsBackupSelection_disappears (17.20s)
--- PASS: TestAccAwsBackupSelection_basic (18.44s)
--- PASS: TestAccAwsBackupSelection_withTags (18.47s)
--- PASS: TestAccAwsBackupSelection_updateTag (28.73s)
```

* tests/resource/aws_backup_selection: Remove wildcard usage in withResources acceptance test

The usage of wildcards differs between AWS Regions while ARNs are supported everywhere.

Previously from acceptance testing:

```
--- FAIL: TestAccAwsBackupSelection_withResources (12.00s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error creating Backup Selection: InvalidParameterValueException: Invalid ARN: arn:aws:elasticfilesystem:us-west-2:--OMITTED--:file-system/. Specified resource is not supported
```

Output from acceptance testing:

```
--- PASS: TestAccAwsBackupSelection_withResources (29.35s)
```

* docs/resource/aws_backup_selection: Expand example documentation to show IAM Role creation and show using resource ARNs

The support for wildcard resource selection does not work in all AWS Regions while ARN support is consistent.

Reference: #9269
@nywilken nywilken added this to the v2.19.0 milestone Jul 10, 2019
@nywilken
Copy link
Member

The fix to the aws_backup_selection resource has been merged and will be released with version 2.19.0 of the Terraform AWS provider.

@bflad
Copy link
Contributor Author

bflad commented Jul 11, 2019

This has been released in version 2.19.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!

@tbugfinder
Copy link
Contributor

I'm wondering if anybody else could execute above code using tf 0.11.14 or tf 0.12.10 ?

In my case it complains about the *.

@ghost
Copy link

ghost commented Nov 1, 2019

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!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/backup Issues and PRs that pertain to the backup service.
Projects
None yet
3 participants