Terraform-provider-aws: Terraform import ValidationError bug

Created on 28 Sep 2017  ยท  5Comments  ยท  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @dovka as hashicorp/terraform#16187. It was migrated here as a result of the provider split. The original body of the issue is below._


Running simple import command
terraform import aws_iam_user.ecrro_user "arn:aws:iam::720999999906:user/test"

results in userName validation error.

Terraform Version

Terraform v0.9.2

Terraform Configuration Files

no custom configuration

Debug Output

Attached
iam_user_validation_error_debug.log

Crash Output

NA

Expected Behavior

Successful import

Actual Behavior

Error importing: 1 error(s) occurred:

  • aws_iam_user.ecrro_user (import id: arn:aws:iam::720999999906:user/test): 1 error(s) occurred:

  • import aws_iam_user.ecrro_user result: arn:aws:iam::720999999906:user/test: aws_iam_user.ecrro_user: Error reading IAM User arn:aws:iam::720999999906:user/test: ValidationError: The specified value for userName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_-
    status code: 400, request id: 068e9497-a2e4-11e7-9056-91d962458027

Steps to Reproduce

terraform import aws_iam_user.ecrro_user "arn:aws:iam::720999999906:user/test"

User ARN is copied from the AWS IAM UI - user exists and is created by terraform:

resource "aws_iam_user" "ecrro_user" {
name = "test"
path = "/"
}

Important Factoids

running directly from shell

References

bug serviciam stale

Most helpful comment

I figured out how to make it work:
it complains because of the slash, cause it expects in place of ID parameter just a user name, not ARN:

terraform import aws_iam_user.test-user test

The policy import expects ARN, and user, role, instance profile expects simple name, NOT ARN.

Ideally import of different objects has to be made consistent - one way or another.

Or at least clearly documented.

All 5 comments

Same issue with ROLE:
arn:aws:iam::720999999906:role/testrole

Exactly same error happens for terraform 1.0.6:

aws_iam_user.ecrro-user: Importing from ID "arn:aws:iam::720999999906:user/test"...
aws_iam_user.ecrro-user: Import complete!
Imported aws_iam_user (ID: arn:aws:iam::720999999906:user/test)
aws_iam_user.ecrro-user: Refreshing state... (ID: arn:aws:iam::720999999906:user/test)
Error importing: 1 error(s) occurred:

  • aws_iam_user.ecrro-user (import id: arn:aws:iam::720999999906:user/test): 1 error(s) occurred:

  • import aws_iam_user.ecrro-user result: arn:aws:iam::720999999906:user/test: aws_iam_user.ecrro-user: Error reading IAM User arn:aws:iam::720999999906:user/ECRRO: ValidationError: The specified value for userName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_-
    status code: 400, request id: 48515731-a6ae-11e7-816d-43092c402102

I figured out how to make it work:
it complains because of the slash, cause it expects in place of ID parameter just a user name, not ARN:

terraform import aws_iam_user.test-user test

The policy import expects ARN, and user, role, instance profile expects simple name, NOT ARN.

Ideally import of different objects has to be made consistent - one way or another.

Or at least clearly documented.

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

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!

Was this page helpful?
0 / 5 - 0 ratings