amazon-web-servicesamazon-ec2boto3amazon-iamaws-auto-scaling

Create the Launch Configuration with boto3


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)

Solution

  • If you have having difficulty creating the instance profile, you can:

    Then, when calling create_launch_configuration(), you can pass the Name or ARN of the Instance Profile that was created.