Skip to content

Commit 8121c66

Browse files
dacbdDavidGOrtega
authored andcommitted
instance_permission_set aws (#232)
* prelim provider tweak with go fmt * get perm value from schema
1 parent c2f940e commit 8121c66

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

iterative/aws/provider.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
3131
securityGroup := d.Get("aws_security_group").(string)
3232
spot := d.Get("spot").(bool)
3333
spotPrice := d.Get("spot_price").(float64)
34+
instanceProfile := d.Get("instance_permission_set").(string)
3435

3536
metadata := map[string]string{
3637
"Name": d.Get("name").(string),
@@ -229,10 +230,13 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
229230
if spot {
230231
requestSpotInstancesInput := &ec2.RequestSpotInstancesInput{
231232
LaunchSpecification: &types.RequestSpotLaunchSpecification{
232-
UserData: aws.String(userData),
233-
ImageId: aws.String(instanceAmi),
234-
KeyName: aws.String(pairName),
235-
InstanceType: types.InstanceType(instanceType),
233+
UserData: aws.String(userData),
234+
ImageId: aws.String(instanceAmi),
235+
KeyName: aws.String(pairName),
236+
InstanceType: types.InstanceType(instanceType),
237+
IamInstanceProfile: &types.IamInstanceProfileSpecification{
238+
Arn: aws.String(instanceProfile),
239+
},
236240
SecurityGroupIds: []string{sgID},
237241
SubnetId: aws.String(subnetID),
238242
BlockDeviceMappings: blockDeviceMappings,
@@ -285,10 +289,13 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
285289
}
286290
} else {
287291
runResult, err := svc.RunInstances(ctx, &ec2.RunInstancesInput{
288-
UserData: aws.String(userData),
289-
ImageId: aws.String(instanceAmi),
290-
KeyName: aws.String(pairName),
291-
InstanceType: types.InstanceType(instanceType),
292+
UserData: aws.String(userData),
293+
ImageId: aws.String(instanceAmi),
294+
KeyName: aws.String(pairName),
295+
InstanceType: types.InstanceType(instanceType),
296+
IamInstanceProfile: &types.IamInstanceProfileSpecification{
297+
Arn: aws.String(instanceProfile),
298+
},
292299
MinCount: aws.Int32(1),
293300
MaxCount: aws.Int32(1),
294301
SecurityGroupIds: []string{sgID},

0 commit comments

Comments
 (0)