Skip to content

Commit

Permalink
Fix passing an instance profile arn to ec2_launch_template
Browse files Browse the repository at this point in the history
If the string given on the iam_instance_profile looked like an arn, the
wrong structure format was being returned. boto3 expects a dict of the
format { arn: "{{ arn }}" } but the string was returned instead.

This fixes this error:
Couldn't create subsequent launch template version: Parameter validation failed:
Invalid type for parameter LaunchTemplateData.IamInstanceProfile, value: arn:aws:iam::[...]:instance-profile/[...], type: <class 'str'>, valid types: <class 'dict'>
  • Loading branch information
kepstin committed Jan 25, 2021
1 parent 1715d79 commit b056911
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/modules/ec2_launch_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@

def determine_iam_role(module, name_or_arn):
if re.match(r'^arn:aws:iam::\d+:instance-profile/[\w+=/,.@-]+$', name_or_arn):
return name_or_arn
return {'arn': name_or_arn}
iam = module.client('iam', retry_decorator=AWSRetry.jittered_backoff())
try:
role = iam.get_instance_profile(InstanceProfileName=name_or_arn, aws_retry=True)
Expand Down

0 comments on commit b056911

Please sign in to comment.