I have a problem with building the launch configuration. I need to make an autoscaling group for the ec2 instance in the subnet, but the problem that I face with iaminstanceprofile I don't know how to do it. could anybody help?
''' create iam role ...
response = iam_client.create_role(
AssumeRolePolicyDocument='\<Stringified-JSON\>',
Path='/',
RoleName='asg-Role',
)
pprint(response)
''' A- Create the Launch Configuration '''
response = AS_client.create_launch_configuration(
IamInstanceProfile='asg-Role',
ImageId='ami-06b09bfacae1453cb',
InstanceType='t2.micro',
LaunchConfigurationName='my-launch-config',
SecurityGroups=[
SG_ec2,],
)
pprint(response)
If you have having difficulty creating the instance profile, you can:
create_instance_profile()
to create Instance Profile object, thenadd_role_to_instance_profile()
to add an IAM Role to the Instance ProfileThen, when calling create_launch_configuration()
, you can pass the Name or ARN of the Instance Profile that was created.