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

issue #4449 Fix the issue using Arn field instead of Name in IamInstanceProfileSpecification #4511

Merged
merged 3 commits into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions aws/resource_aws_spot_fleet_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ func resourceAwsSpotFleetRequest() *schema.Resource {
ForceNew: true,
Optional: true,
},
"iam_instance_profile_arn": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please

  • Document the new argument in the argument reference near the existing iam_instance_profile argument
  • Add a simple acceptance test to cover this new argument? Copy pasting an existing test and test configuration that uses iam_instance_profile is fine 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented the new argument under launch_specification section and added the acceptance test.

Type: schema.TypeString,
ForceNew: true,
Optional: true,
},
"ami": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -376,6 +381,12 @@ func buildSpotFleetLaunchSpecification(d map[string]interface{}, meta interface{
}
}

if v, ok := d["iam_instance_profile_arn"]; ok {
opts.IamInstanceProfile = &ec2.IamInstanceProfileSpecification{
Arn: aws.String(v.(string)),
}
}

if v, ok := d["user_data"]; ok {
opts.UserData = aws.String(base64Encode([]byte(v.(string))))
}
Expand Down Expand Up @@ -939,6 +950,10 @@ func launchSpecToMap(l *ec2.SpotFleetLaunchSpecification, rootDevName *string) m
m["iam_instance_profile"] = aws.StringValue(l.IamInstanceProfile.Name)
}

if l.IamInstanceProfile != nil && l.IamInstanceProfile.Arn != nil {
m["iam_instance_profile_arn"] = aws.StringValue(l.IamInstanceProfile.Arn)
}

if l.UserData != nil {
m["user_data"] = userDataHashSum(aws.StringValue(l.UserData))
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/spot_fleet_request.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ resource "aws_spot_fleet_request" "cheap_compute" {
ami = "ami-1234"
spot_price = "2.793"
placement_tenancy = "dedicated"
iam_instance_profile_arn = "arn:aws:iam::12345678:instance-profile/webserver-role"
Copy link
Contributor

@bflad bflad May 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either fix this so its a properly formatted ARN (account ID is 12 digits 123456789012) or just reference a "fake" resource ("${aws_iam_instance_profile.example.arn}"). Also as a nitpick, if these are going to be added in here, please line up all the equals symbols similar to how terraform fmt would e.g.

ami                      = "ami-1234"
spot_price               = "2.793"
placement_tenancy        = "dedicated"
iam_instance_profile_arn = "${aws_iam_instance_profile.example.arn}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

}

launch_specification {
instance_type = "m4.4xlarge"
ami = "ami-5678"
key_name = "my-key"
spot_price = "1.117"
iam_instance_profile_arn = "arn:aws:iam::12345678:instance-profile/webserver-role"
availability_zone = "us-west-1a"
subnet_id = "subnet-1234"
weighted_capacity = 35
Expand Down