iam_instance_profile

294 views
Skip to first unread message

Jerry Steele

unread,
Jan 29, 2016, 9:49:33 AM1/29/16
to Terraform
Hiya,

I would like an existing instance profile (from another Terraform config) to be used in a sandbox environment I am configuring. The code for bringing the instance up looks like this:
{
resource "aws_instance" "web" {
  ami = "ami-xxxxxx"
  instance_type = "t2.micro"
  vpc_security_group_ids = [
  ]
  subnet_id = "${aws_subnet.default.id}"
  ebs_optimized = false
  user_data = "${file("user_data.tmpl")}"
  associate_public_ip_address = true
  iam_instance_profile = "arn:aws:iam::44400000000:instance-profile/blah"
}

When I run a "terraform plan", I get:

Error applying plan:

1 error(s) occurred:

* aws_instance.web: Error launching source instance: InvalidParameterValue: Value (arn:aws:iam::44400000000:instance-profile/blah) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name
status code: 400, request id:

(Note that some of the code above has been obfuscated for obvious reasons)

I don't have the aws_iam_instance_profile resource defined in this scope to be able to reference the attribute (e.g. "${aws_iam_instance_profile.blah.name}"), but it already exists elsewhere in my infrastructure.

Is it possible to do this in Terraform?

Thanks

Jerry

Dominic Valentino

unread,
Sep 9, 2016, 12:59:49 PM9/9/16
to Terraform
Hi Jerry,
did you every figure this out? I have the same question/need to use an existing instance profile.

Thanks
Reply all
Reply to author
Forward
0 new messages