Last active
October 21, 2019 13:48
-
-
Save philschmid/d97a80ca02d27fef07a03e815edd16ef to your computer and use it in GitHub Desktop.
boto3 start ec2 instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
client = boto3.client('ec2', region_name='us-west-2') | |
user_data= '''#!/bin/bash | |
echo 'test' > /tmp/hello''' | |
response = client.run_instances( | |
BlockDeviceMappings=[ | |
{ | |
'DeviceName': '/dev/xvda', | |
'Ebs': { | |
'DeleteOnTermination': True, | |
'VolumeSize': 8, | |
'VolumeType': 'gp2' | |
}, | |
}, | |
], | |
ImageId='ami-6cd6f714', | |
InstanceType='t3.micro', | |
MaxCount=1, | |
MinCount=1, | |
Monitoring={ | |
'Enabled': False | |
}, | |
SecurityGroupIds=[ | |
'sg-1f39854x', | |
], | |
user_data=user_data, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/mickep76/docker-build-ami
https://pypi.org/project/docker-build-ami/0.1.3/