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

IAM instance profile not created fast enough to modify EC2 instance #15199

Closed
b-dean opened this issue Jun 8, 2017 · 1 comment
Closed

IAM instance profile not created fast enough to modify EC2 instance #15199

b-dean opened this issue Jun 8, 2017 · 1 comment

Comments

@b-dean
Copy link

b-dean commented Jun 8, 2017

When creating an IAM instance profile and modifying an EC2 instance to use it, I get the error: Invalid IAM Instance Profile name

This seems to be the same sort of thing that was reported in #1885 and fixed by #2037. The difference being this is when an EC2 instance is modified, not when it is created.

Terraform Version

0.9.8

Affected Resource(s)

  • aws_instance

Terraform Configuration Files

data "aws_iam_policy_document" "assume_role" {
  statement {
    effect = "Allow"

    actions = [
      "sts:AssumeRole",
    ]

    principals {
      type = "Service"
      identifiers = [
        "ec2.amazonaws.com",
      ]
    }
  }
}

data "aws_ami" "amazon" {
  most_recent = true
  filter {
    name   = "owner-alias"
    values = ["amazon"]
  }

  filter {
    name   = "name"
    values = ["amzn-ami-hvm-2017.03.*-x86_64-ebs"]
  }
}

/*
resource "aws_iam_role" "foo" {
  name = "foo"
  assume_role_policy = "${data.aws_iam_policy_document.assume_role.json}"
}

resource "aws_iam_instance_profile" "foo" {
  name = "foo"
  role = "${aws_iam_role.foo.name}"
}
*/

resource "aws_instance" "foo" {
  ami = "${data.aws_ami.amazon.id}"
  instance_type = "t2.nano"
  // iam_instance_profile = "${aws_iam_instance_profile.foo.name}"
}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply to create the EC2 instance
  2. Edit the tf file to uncomment the aws_iam_role.foo, aws_iam_instance_profile.foo, and the iam_instance_profile argument on the aws_instance.foo resource
  3. terraform apply to create the EC2 instance

Expected Behavior

The aws_iam_role and aws_iam_instance_profile should be created and the aws_instance modified to use the instance profile.

Actual Behavior

The aws_iam_role and aws_iam_instance_profile are created fine, but when the aws_instance is being modified the following error occurs:

Error applying plan:

1 error(s) occurred:

* aws_instance.foo: 1 error(s) occurred:

* aws_instance.foo: InvalidParameterValue: Value (foo) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name
	status code: 400, request id: 9e5d217e-6b5d-41dc-a856-f2d5b31747a6

References

@ghost
Copy link

ghost commented Apr 9, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants