-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsgbase.py
More file actions
executable file
·71 lines (64 loc) · 1.86 KB
/
sgbase.py
File metadata and controls
executable file
·71 lines (64 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
"""
Script to create bas service group.
"""
# from troposphere import Base64, FindInMap, GetAtt, Tags
# from troposphere import Parameter, Output, Ref, Template, ImportValue
# from troposphere import Condition, Equals, And, Or, Not, If, Join
# from troposphere.ec2 import SecurityGroup, NetworkInterfaceProperty, Instance, Volume
# from troposphere.ec2 import SecurityGroupRule
import json
import yaml ### for yaml output
from troposphere import Parameter, Template, Ref
from troposphere.ec2 import SecurityGroup, SecurityGroupIngress, SecurityGroupEgress
t = Template()
###
### parameters
###
#
# vpc_param = t.add_parameter(Parameter(
# 'VPC',
# ConstraintDescription='must be the VPC Id of an existing VPC.',
# Description='VPC Id of existing VPC',
# Type='AWS::EC2::VPC::Id',
# # Default=Ref(ref_MigrationVPC)
# ))
inrule = t.add_parameter(Parameter(
'inrule',
Description='IngressRule',
Default='[{"CidrIp":"0.0.0.0/0","IpProtocol":"tcp","FromPort":"22","ToPort":"22"}]',
Type='String'
))
###
### Conditions
###
###
### Resources
###
t.add_resource(SecurityGroup(
'BaseSecurityGroup',
GroupDescription='Security group base',
VpcId='vpc-f5eb1c91',
))
t.add_resource(SecurityGroupIngress(
'InternalBaseIngress',
DependsOn="BaseSecurityGroup",
GroupId=Ref("BaseSecurityGroup"),
IpProtocol="-1",
SourceSecurityGroupId=Ref("BaseSecurityGroup")
))
t.add_resource(SecurityGroupEgress(
'InternalBaseEgress',
DependsOn="BaseSecurityGroup",
GroupId=Ref("BaseSecurityGroup"),
IpProtocol="-1",
FromPort="0",
ToPort="65535",
SourceSecurityGroupId=Ref("BaseSecurityGroup")
))
###
### Outputs...
###
# print t.to_json()
### for yaml output...
print yaml.safe_dump(json.loads(t.to_json()), None, allow_unicode=True)