Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_implicit_ref_in_a_tuple(self):
t = Template()
r1 = FakeAWSObject('r1')
t.add_resource(r1)
r2 = FakeAWSObject('r2', listproperty=[1, (2, r1)])
t.add_resource(r2)
self.assertJsonEquals(t, {
'Resources': {
'r1': {
'Type': "Fake::AWS::Object",
},
'r2': {
'Type': "Fake::AWS::Object",
'Properties': {
'listproperty': [
1,
[
2,
def test_parameter_group(self):
t = Template()
p1 = t.add_parameter(Parameter("Foo"))
t.add_parameter(Parameter("Bar"))
t.add_parameter_to_group(p1, "gr")
t.add_parameter_to_group("Bar", "gr")
self.assertEqual(t.metadata, {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {"default": "gr"},
"Parameters": ["Foo", "Bar"],
},
def __init__(self):
self.name = 'ec2.template'
self.template = Template()
self.template.add_version("2010-09-09")
self.test_parameter_groups = TestParameterGroups()
default_test_params = TestParameterGroup()
self.test_parameter_groups.add(default_test_params)
Environment = self.template.add_parameter(Parameter(
"Environment",
Default="Development",
Type="String",
Description="Application environment",
AllowedValues=["Development", "Integration",
"PreProduction", "Production", "Staging", "Test"],
))
default_test_params.add(TestParameter("Environment", "Integration"))
def _base_troposphere_template(self):
"""Returns the most basic troposphere template possible"""
template = troposphere.Template()
template.add_parameter(
troposphere.Parameter(
"Stage",
Default="dev",
Description="Name of the Stage",
Type="String",
)
)
template.add_parameter(
troposphere.Parameter(
"Region",
Description="AWS Region",
Type="String",
)
)
# Converted from Route53_A.template located at:
# http://aws.amazon.com/cloudformation/aws-cloudformation-templates/
from troposphere import FindInMap, GetAtt, Join, Output
from troposphere import Parameter, Ref, Template
from troposphere.ec2 import Instance
from troposphere.route53 import RecordSetType
t = Template()
t.set_description(
"AWS CloudFormation Sample Template Route53_A: "
"Sample template showing how to create an Amazon Route 53 A record that "
"maps to the public IP address of an EC2 instance. It assumes that you "
"already have a Hosted Zone registered with Amazon Route 53. **WARNING** "
"This template creates an Amazon EC2 instance. You will be billed for "
"the AWS resources used if you create a stack from this template.")
hostedzone = t.add_parameter(Parameter(
"HostedZone",
Description="The DNS name of an existing Amazon Route 53 hosted zone",
Type="String",
))
t.add_mapping('RegionMap', {
def main(args):
number_of_vol = 5
t = Template()
availability_zone = t.add_parameter(
Parameter(
"AvailabilityZone",
Type="String",
Description="Availability Zone the cluster will launch into. " "THIS IS REQUIRED",
)
)
raid_options = t.add_parameter(
Parameter(
"RAIDOptions",
Type="CommaDelimitedList",
Description="Comma separated list of RAID related options, "
"8 parameters in total, "
"["
"0 shared_dir,"
"1 raid_type,"
# Converted from VPC_With_VPN_Connection.template located at:
# http://aws.amazon.com/cloudformation/aws-cloudformation-templates
from troposphere import Base64, FindInMap, GetAtt, Join, Output
from troposphere import Parameter, Ref, Tags, Template
from troposphere.autoscaling import Metadata
from troposphere.ec2 import PortRange, NetworkAcl, Route, \
VPCGatewayAttachment, SubnetRouteTableAssociation, Subnet, RouteTable, \
VPC, NetworkInterfaceProperty, NetworkAclEntry, \
SubnetNetworkAclAssociation, EIP, Instance, InternetGateway, \
SecurityGroupRule, SecurityGroup
from troposphere.policies import CreationPolicy, ResourceSignal
from troposphere.cloudformation import Init, InitFile, InitFiles, \
InitConfig, InitService, InitServices
t = Template()
t.add_version('2010-09-09')
t.set_description("""\
AWS CloudFormation Sample Template VPC_Single_Instance_In_Subnet: Sample \
template showing how to create a VPC and add an EC2 instance with an Elastic \
IP address and a security group. \
**WARNING** This template creates an Amazon EC2 instance. You will be billed \
for the AWS resources used if you create a stack from this template.""")
keyname_param = t.add_parameter(
Parameter(
'KeyName',
ConstraintDescription='must be the name of an existing EC2 KeyPair.',
Description='Name of an existing EC2 KeyPair to enable SSH access to \
the instance',
from troposphere import GetAtt, Template, Tags
from troposphere.dlm import (LifecyclePolicy, PolicyDetails, Schedule,
RetainRule, CreateRule)
from troposphere.iam import Role
from awacs.aws import Allow, Statement, Principal, PolicyDocument
from awacs.sts import AssumeRole
t = Template()
t.add_version('2010-09-09')
dlm_role = t.add_resource(Role(
"DlmRole",
AssumeRolePolicyDocument=PolicyDocument(
Statement=[
Statement(
Effect=Allow,
Action=[AssumeRole],
Principal=Principal("Service", ["ec2.amazonaws.com"])
)
]
)
))
lifecycle_policy = t.add_resource(LifecyclePolicy(
def main(args):
t = Template()
# ================= Parameters =================
# 0 1 2 3 4 5 6 7
# [shared_dir,fsx_fs_id,storage_capacity,fsx_kms_key_id,imported_file_chunk_size,export_path,import_path,weekly_maintenance_start_time]
fsx_options = t.add_parameter(
Parameter(
"FSXOptions",
Type="CommaDelimitedList",
Description="Comma separated list of fsx related options, 8 parameters in total, [shared_dir,fsx_fs_id,storage_capacity,fsx_kms_key_id,imported_file_chunk_size,export_path,import_path,weekly_maintenance_start_time]",
)
)
compute_security_group = t.add_parameter(
Parameter("ComputeSecurityGroup", Type="String", Description="SecurityGroup for FSx filesystem")
)
from troposphere import (
Template, iam, GetAtt, Join, Ref, logs, Select, Export, Output, Parameter, awslambda, Base64, ImportValue, Sub
)
from awacs.aws import Policy, Allow, Statement, Principal, Action
from cfn_encrypt import Encrypt
t = Template()
datadog_api_key = t.add_parameter(Parameter(
"DatadogApiKey",
Type="String",
Description="Datadog api key",
NoEcho=True
))
datadog_application_key = t.add_parameter(Parameter(
"DatadogApplicationKey",
Type="String",
Description="Datadog application key",
NoEcho=True
))
encrypt_lambda_stack = t.add_parameter(Parameter(