Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python
- import boto3
- import sys, re
- region = 'ap-southeast-2'
- s3 = boto3.resource('s3')
- client = boto3.client('cloudformation', region_name=region)
- cfn = boto3.resource('cloudformation', region_name=region)
- match_hybris = re.compile('HYBRIS')
- ec2 = boto3.client('ec2', region_name=region)
- for stack in cfn.stacks.all():
- if match_hybris.match(stack.stack_name):
- stack_resources = client.describe_stack_resources(
- StackName=stack.stack_name
- )
- print("Stack: " + stack.stack_name)
- for resource in stack_resources['StackResources']:
- if resource['ResourceType'] == 'AWS::EC2::Instance': #in ( 'AWS::EC2::Instance', 'AWS::Route53::RecordSet'):
- instance = ec2.describe_instances(
- InstanceIds=[resource['PhysicalResourceId']]
- )
- print("\tInstance: " + resource['LogicalResourceId'] + " instance-id: " + resource['PhysicalResourceId']
- + " IP: " + instance['Reservations'][0]['Instances'][0]['PrivateIpAddress'])
- if resource['ResourceType'] == 'AWS::Route53::RecordSet':
- print("\tDNS: " + resource['LogicalResourceId'] + " record: " + resource['PhysicalResourceId'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement