_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 v0.9.2
no custom configuration
Attached
iam_user_validation_error_debug.log
NA
Successful import
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
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 = "/"
}
running directly from shell
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:
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!
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.