Created
December 11, 2022 22:24
-
-
Save davila7/39445b674d1da8c48e6e2e6f717b0ea3 to your computer and use it in GitHub Desktop.
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
| # Definimos nuestro tag | |
| tag_name = 'Staging' | |
| #instancias EC2 | |
| ec2 = boto3.resource('ec2', region_name='us-east-1') | |
| instances = ec2.instances.filter(Filters=[ | |
| { | |
| 'Name': 'instance-state-name', | |
| 'Values': ['stopped'] | |
| }, | |
| { | |
| 'Name': 'tag:Env', | |
| 'Values':[tag_name] | |
| } | |
| ]) | |
| for instance in instances: | |
| id = instance.id | |
| ec2.instances.filter(InstanceIds=[id]).start() | |
| print('Instancia encendida : ' + str(id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment