Esempio n. 1
0
# miscTransitions = []
# lifeCycleRules.append(CreateLifeCycleRules("Misc", "/Misc/Pics", "3650", "Enabled", miscTransitions))
# miscTransitions.append(CreateLifecycleRuleTransition("STANDARD_IA", "90"))
# miscTransitions.append(CreateLifecycleRuleTransition("GLACIER", "365"))

lifeCycleConfiguration = s3.LifecycleConfiguration(Rules=lifeCycleRules)

template.add_resource(
    Bucket("JHSBucket",
           BucketName=Ref(bucketName),
           LifecycleConfiguration=lifeCycleConfiguration))

#Adding Output By Passing Object
myOutput = Output("JHSBucketName")
myOutput.Description = "This is the name of personal bucket"
myOutput.Value = Ref(bucketName)
template.add_output(myOutput)

#Adding Output Directly
template.add_output(
    Output("DirectOutput",
           Description="This is an alternative form of adding outputs",
           Value=Join(
               "",
               ["BucketName is ", Ref(bucketName), " On S3"])))


def CreateTemplate(filename, t):
    os.chdir("..")
    try:
        os.mkdir("templates")
Esempio n. 2
0
t.add_resource(subnet_1a)

#Subnet 1b
subnet_1b = ec2.Subnet(
"MySubnet1b",
AvailabilityZone="us-east-1b",
CidrBlock="10.0.1.0/24", # ADJUST THIS VALUE
VpcId=GetAtt(subnet_1a, "VpcId"),
Tags=Tags(
Name="learncf-1b",
Comment="CloudFormation+Troposphere test"))
t.add_resource(subnet_1b)

#Subnet 1 Output
out_subnet_1a = Output("outMySubnet1a")
out_subnet_1a.Value = Ref(subnet_1a)
out_subnet_1a.Export = Export(Sub(
"${AWS::StackName}-" + subnet_1a.title))

# Similar output for the second subnet
out_subnet_1b = Output("outMySubnet1b")
out_subnet_1b.Value = Ref(subnet_1b)
out_subnet_1b.Export = Export(Sub(
"${AWS::StackName}-" + subnet_1b.title))

# Add outputs to template
t.add_output(out_subnet_1a)
t.add_output(out_subnet_1b)

# Finally, write the template to a file
with open('learncf-subnet.json', 'w') as f: