Skip to content

Instantly share code, notes, and snippets.

@davila7
Created December 11, 2022 22:24
Show Gist options
  • Select an option

  • Save davila7/39445b674d1da8c48e6e2e6f717b0ea3 to your computer and use it in GitHub Desktop.

Select an option

Save davila7/39445b674d1da8c48e6e2e6f717b0ea3 to your computer and use it in GitHub Desktop.
# 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