How to use the troposphere.If function in troposphere

To help you get started, we’ve selected a few troposphere examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onicagroup / runway / runway / blueprints / tf_state.py View on Github external
dynamodb.AttributeDefinition(
                        AttributeName='LockID',
                        AttributeType='S'
                    )
                ],
                KeySchema=[
                    dynamodb.KeySchema(
                        AttributeName='LockID',
                        KeyType='HASH'
                    )
                ],
                ProvisionedThroughput=dynamodb.ProvisionedThroughput(
                    ReadCapacityUnits=2,
                    WriteCapacityUnits=2
                ),
                TableName=If(
                    'TableNameOmitted',
                    NoValue,
                    variables['TableName'].ref
                )
            )
        )
        template.add_output(Output(
            '%sName' % terraformlocktable.title,
            Description='Name of DynamoDB table for Terraform state',
            Value=terraformlocktable.ref()
        ))

        terraformstatebucket = template.add_resource(
            s3.Bucket(
                'TerraformStateBucket',
                DeletionPolicy='Retain',
github cloudtools / troposphere / examples / EMR_Cluster.py View on Github external
Name="Master Instance",
            InstanceCount="1",
            InstanceType=M4_LARGE,
            Market="ON_DEMAND",
            AutoScalingPolicy=emr.AutoScalingPolicy(
                Constraints=emr.ScalingConstraints(
                    MinCapacity="1",
                    MaxCapacity="3"
                ),
                Rules=generate_rules("MasterAutoScalingPolicy")
            )
        ),
        CoreInstanceGroup=emr.InstanceGroupConfigProperty(
            Name="Core Instance",
            BidPrice=If(withSpotPrice, Ref(spot), Ref("AWS::NoValue")),
            Market=If(withSpotPrice, "SPOT", "ON_DEMAND"),
            AutoScalingPolicy=emr.AutoScalingPolicy(
                Constraints=emr.ScalingConstraints(
                    MinCapacity="1",
                    MaxCapacity="3"
                ),
                Rules=generate_rules("CoreAutoScalingPolicy"),
            ),
            EbsConfiguration=emr.EbsConfiguration(
                EbsBlockDeviceConfigs=[
                    emr.EbsBlockDeviceConfigs(
                        VolumeSpecification=emr.VolumeSpecification(
                            SizeInGB="10",
                            VolumeType="gp2"
                        ),
                        VolumesPerInstance="1"
                    )
github remind101 / stacker_blueprints / stacker_blueprints / empire / daemon.py View on Github external
Value="conveyor"),
            ecs.Environment(
                Name="EMPIRE_CONVEYOR_URL",
                Value=Ref("ConveyorUrl")),
            ecs.Environment(
                Name="EMPIRE_RUN_LOGS_BACKEND",
                Value=Ref("RunLogsBackend")),
            ecs.Environment(
                Name="EMPIRE_CUSTOM_RESOURCES_TOPIC",
                Value=Ref("CustomResourcesTopic")),
            ecs.Environment(
                Name="EMPIRE_CUSTOM_RESOURCES_QUEUE",
                Value=Ref("CustomResourcesQueue")),
            ecs.Environment(
                Name="EMPIRE_CLOUDWATCH_LOG_GROUP",
                Value=If(
                    "EnableCloudwatchLogs",
                    Ref(RUN_LOGS),
                    "AWS::NoValue")),
            If(
                'RequireCommitMessages',
                ecs.Environment(Name='EMPIRE_MESSAGES_REQUIRED', Value='true'),
                Ref('AWS::NoValue')
            ),
github vrtdev / aws-cloudfront-authorizer / templates / authorizer.py View on Github external
],
        }]
    }
))

common_lambda_options = {
    'Runtime': 'python3.6',
    'Timeout': 10,  # Cold start sometimes takes longer than the default 3 seconds
    'CodeUri': serverless.S3Location('unused', Bucket=Ref(param_s3_bucket_name), Key=Ref(param_s3_key)),
    'Environment': awslambda.Environment(
        Variables={
            "COGNITO_USER_POOL_ID": Ref(cognito_user_pool),
            "COGNITO_DOMAIN_PREFIX": GetAtt(cognito_user_pool_domain, 'Domain'),
            "COGNITO_CLIENT_ID": Ref(cognito_user_pool_client),
            "COGNITO_CLIENT_SECRET": GetAtt(cognito_user_pool_client, 'ClientSecret'),
            "COGNITO_ADFS_IDP_NAME": If(AUTO_USE_ADFS, adfs_provider_name, 'COGNITO'),
            "DOMAIN_NAME": Join('.', [Ref(param_label), Ref(param_hosted_zone_name)]),
            "CONFIG_BUCKET": Ref(config_bucket),
        }
    ),
    'Role': GetAtt(lambda_role, 'Arn'),
}

template.add_resource(serverless.Function(
    "Index",
    **common_lambda_options,
    Handler='index.handler',
    Events={
        'Index': serverless.ApiEvent(
            'unused',
            Path='/',
            Method='GET',
github aws / aws-parallelcluster / util / cfn-stacks-generators / generate-fsx-substack.py View on Github external
use_weekly_mainenance_start_time = t.add_condition(
        "UseWeeklyMaintenanceStartTime", Not(Equals(Select(str(7), Ref(fsx_options)), "NONE"))
    )

    # ================= Resources =================
    fs = t.add_resource(
        FileSystem(
            "FileSystem",
            FileSystemType="LUSTRE",
            SubnetIds=[Ref(subnet_id)],
            SecurityGroupIds=[Ref(compute_security_group)],
            KmsKeyId=If(use_fsx_kms_key, Select(str(3), Ref(fsx_options)), NoValue),
            StorageCapacity=If(use_storage_capacity, Select(str(2), Ref(fsx_options)), NoValue),
            LustreConfiguration=LustreConfiguration(
                ImportedFileChunkSize=If(use_imported_file_chunk_size, Select(str(4), Ref(fsx_options)), NoValue),
                ExportPath=If(use_export_path, Select(str(5), Ref(fsx_options)), NoValue),
                ImportPath=If(use_import_path, Select(str(6), Ref(fsx_options)), NoValue),
                WeeklyMaintenanceStartTime=If(
                    use_weekly_mainenance_start_time, Select(str(7), Ref(fsx_options)), NoValue
                ),
            ),
            Condition=create_fsx,
        )
    )

    # ================= Outputs =================
    t.add_output(
        Output(
            "FileSystemId",
            Description="ID of the FileSystem",
            Value=If(create_fsx, Ref(fs), Select("1", Ref(fsx_options))),
        )
github remind101 / stacker_blueprints / stacker_blueprints / empire / daemon.py View on Github external
ecs.Environment(
                Name="EMPIRE_RUN_LOGS_BACKEND",
                Value=Ref("RunLogsBackend")),
            ecs.Environment(
                Name="EMPIRE_CUSTOM_RESOURCES_TOPIC",
                Value=Ref("CustomResourcesTopic")),
            ecs.Environment(
                Name="EMPIRE_CUSTOM_RESOURCES_QUEUE",
                Value=Ref("CustomResourcesQueue")),
            ecs.Environment(
                Name="EMPIRE_CLOUDWATCH_LOG_GROUP",
                Value=If(
                    "EnableCloudwatchLogs",
                    Ref(RUN_LOGS),
                    "AWS::NoValue")),
            If(
                'RequireCommitMessages',
                ecs.Environment(Name='EMPIRE_MESSAGES_REQUIRED', Value='true'),
                Ref('AWS::NoValue')
            ),
github caktus / aws-web-stacks / stack / common.py View on Github external
from troposphere import AWS_REGION, Equals, If, Not, Ref

from .template import template
from .utils import ParameterWithDefaults as Parameter

dont_create_value = "(none)"

in_govcloud_region = "InGovCloudRegion"
template.add_condition(in_govcloud_region, Equals(Ref(AWS_REGION), "us-gov-west-1"))
arn_prefix = If(in_govcloud_region, "arn:aws-us-gov", "arn:aws")

administrator_ip_address = Ref(template.add_parameter(
    Parameter(
        "AdministratorIPAddress",
        Description="The IP address allowed to access containers. "
                    "Defaults to TEST-NET-1 (ie, no valid IP)",
        Type="String",
        # RFC5737 - TEST-NET-1 reserved for documentation
        Default="192.0.2.0/24",
    ),
    group="Application Server",
    label="Admin IP Address",
))

container_instance_type = Ref(template.add_parameter(
    Parameter(
github caktus / fabulaws / vpc-template / stack / assets.py View on Github external
group="Static Media",
    label="CloudFront SSL Certificate ARN",
)
assets_certificate_arn_condition = "AssetsCloudFrontCertArnCondition"
template.add_condition(
    assets_certificate_arn_condition, Not(Equals(Ref(assets_certificate_arn), ""))
)

for environment, bucket_map in buckets.items():
    # Create a CloudFront CDN distribution
    distribution = template.add_resource(
        Distribution(
            "AssetsDistribution%s" % environment.title(),
            Condition=assets_use_cloudfront_condition,
            DistributionConfig=DistributionConfig(
                Aliases=If(
                    assets_custom_domain_condition,
                    [Ref(assets_cloudfront_domain)],
                    Ref("AWS::NoValue"),
                ),
                # use the ACM certificate we created (if any), otherwise fall back to the manually-supplied
                # ARN (if any)
                ViewerCertificate=If(
                    assets_custom_domain_and_us_east_1_condition,
                    ViewerCertificate(
                        AcmCertificateArn=Ref(assets_certificate),
                        SslSupportMethod="sni-only",
                    ),
                    If(
                        assets_certificate_arn_condition,
                        ViewerCertificate(
                            AcmCertificateArn=Ref(assets_certificate_arn),
github cloudtools / stacker / stacker / blueprints / rds / base.py View on Github external
def create_rds(self):
        t = self.template
        t.add_resource(
            DBInstance(
                DBINSTANCE,
                StorageType=If("HasStorageType",
                               Ref("StorageType"),
                               Ref("AWS::NoValue")),
                Iops=If("HasProvisionedIOPS",
                        Ref("IOPS"),
                        Ref("AWS::NoValue")),
                **self.get_common_attrs()))