Skip to content
v2.278.0

CfnConnectionGroupProps Struct ​

Properties for defining a CfnConnectionGroup.

Example ​

ts
import * as route53 from 'aws-cdk-lib/aws-route53';

// Create the simple Origin
const myBucket = new s3.Bucket(this, 'myBucket');
const s3Origin = origins.S3BucketOrigin.withOriginAccessControl(myBucket, {
    originAccessLevels: [cloudfront.AccessLevel.READ, cloudfront.AccessLevel.LIST],
});

// Create the Distribution construct
const myMultiTenantDistribution = new cloudfront.Distribution(this, 'cf-hosted-distribution', {
    defaultBehavior: {
        origin: s3Origin,
    },
    defaultRootObject: 'index.html', // recommended to specify
});

// Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
const cfnDistribution = myMultiTenantDistribution.node.defaultChild as cloudfront.CfnDistribution;

const defaultCacheBehavior: cloudfront.CfnDistribution.DefaultCacheBehaviorProperty = {
    targetOriginId: myBucket.bucketArn,
    viewerProtocolPolicy: 'allow-all',
    compress: false,
    allowedMethods: ['GET', 'HEAD'],
    cachePolicyId: cloudfront.CachePolicy.CACHING_OPTIMIZED.cachePolicyId
};
// Create the updated distributionConfig
const distributionConfig: cloudfront.CfnDistribution.DistributionConfigProperty = {
    defaultCacheBehavior: defaultCacheBehavior,
    enabled: true,
    // the properties below are optional
    connectionMode: 'tenant-only',
    origins: [
        {
            id: myBucket.bucketArn,
            domainName: myBucket.bucketDomainName,
            s3OriginConfig: {},
            originPath: "/{{tenantName}}"
        },
    ],
    tenantConfig: {
        parameterDefinitions: [
            {
                definition: {
                    stringSchema: {
                        required: false,
                        // the properties below are optional
                        comment: 'tenantName',
                        defaultValue: 'root',
                    },
                },
                name: 'tenantName',
            },
        ],
    },
};

// Override the distribution configuration to enable multi-tenancy.
cfnDistribution.distributionConfig = distributionConfig;

// Create a connection group and a cname record in an existing hosted zone to validate domain ownership
const connectionGroup = new cloudfront.CfnConnectionGroup(this, 'cf-hosted-connection-group', {
    enabled: true,
    ipv6Enabled: true,
    name: 'my-connection-group',
});

// Import the existing hosted zone info, replacing with your hostedZoneId and zoneName
const hostedZoneId = 'YOUR_HOSTED_ZONE_ID';
const zoneName = 'my.domain.com';
const hostedZone = route53.HostedZone.fromHostedZoneAttributes(this, 'hosted-zone', {
    hostedZoneId,
    zoneName,
});

const record = new route53.CnameRecord(this, 'cname-record', {
    domainName: connectionGroup.attrRoutingEndpoint,
    zone: hostedZone,
    recordName: 'cf-hosted-tenant.my.domain.com',
});

// Create the cloudfront-hosted tenant, passing in the previously created connection group
const cloudfrontHostedTenant = new cloudfront.CfnDistributionTenant(this, 'cf-hosted-tenant', {
    distributionId: myMultiTenantDistribution.distributionId,
    name: 'cf-hosted-tenant',
    domains: ['cf-hosted-tenant.my.domain.com'],
    connectionGroupId: connectionGroup.attrId,
    enabled: true,
    managedCertificateRequest: {
        validationTokenHost: 'cloudfront'
    },
});
python
import aws_cdk.aws_route53 as route53


# Create the simple Origin
my_bucket = s3.Bucket(self, "myBucket")
s3_origin = origins.S3BucketOrigin.with_origin_access_control(my_bucket,
    origin_access_levels=[cloudfront.AccessLevel.READ, cloudfront.AccessLevel.LIST]
)

# Create the Distribution construct
my_multi_tenant_distribution = cloudfront.Distribution(self, "cf-hosted-distribution",
    default_behavior=cloudfront.BehaviorOptions(
        origin=s3_origin
    ),
    default_root_object="index.html"
)

# Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
cfn_distribution = my_multi_tenant_distribution.node.default_child

default_cache_behavior = cloudfront.CfnDistribution.DefaultCacheBehaviorProperty(
    target_origin_id=my_bucket.bucket_arn,
    viewer_protocol_policy="allow-all",
    compress=False,
    allowed_methods=["GET", "HEAD"],
    cache_policy_id=cloudfront.CachePolicy.CACHING_OPTIMIZED.cache_policy_id
)
# Create the updated distributionConfig
distribution_config = cloudfront.CfnDistribution.DistributionConfigProperty(
    default_cache_behavior=default_cache_behavior,
    enabled=True,
    # the properties below are optional
    connection_mode="tenant-only",
    origins=[cloudfront.CfnDistribution.OriginProperty(
        id=my_bucket.bucket_arn,
        domain_name=my_bucket.bucket_domain_name,
        s3_origin_config=cloudfront.CfnDistribution.S3OriginConfigProperty(),
        origin_path="/{{tenantName}}"
    )
    ],
    tenant_config=cloudfront.CfnDistribution.TenantConfigProperty(
        parameter_definitions=[cloudfront.CfnDistribution.ParameterDefinitionProperty(
            definition=cloudfront.CfnDistribution.DefinitionProperty(
                string_schema=cloudfront.CfnDistribution.StringSchemaProperty(
                    required=False,
                    # the properties below are optional
                    comment="tenantName",
                    default_value="root"
                )
            ),
            name="tenantName"
        )
        ]
    )
)

# Override the distribution configuration to enable multi-tenancy.
cfn_distribution.distribution_config = distribution_config

# Create a connection group and a cname record in an existing hosted zone to validate domain ownership
connection_group = cloudfront.CfnConnectionGroup(self, "cf-hosted-connection-group",
    enabled=True,
    ipv6_enabled=True,
    name="my-connection-group"
)

# Import the existing hosted zone info, replacing with your hostedZoneId and zoneName
hosted_zone_id = "YOUR_HOSTED_ZONE_ID"
zone_name = "my.domain.com"
hosted_zone = route53.HostedZone.from_hosted_zone_attributes(self, "hosted-zone",
    hosted_zone_id=hosted_zone_id,
    zone_name=zone_name
)

record = route53.CnameRecord(self, "cname-record",
    domain_name=connection_group.attr_routing_endpoint,
    zone=hosted_zone,
    record_name="cf-hosted-tenant.my.domain.com"
)

# Create the cloudfront-hosted tenant, passing in the previously created connection group
cloudfront_hosted_tenant = cloudfront.CfnDistributionTenant(self, "cf-hosted-tenant",
    distribution_id=my_multi_tenant_distribution.distribution_id,
    name="cf-hosted-tenant",
    domains=["cf-hosted-tenant.my.domain.com"],
    connection_group_id=connection_group.attr_id,
    enabled=True,
    managed_certificate_request=cloudfront.CfnDistributionTenant.ManagedCertificateRequestProperty(
        validation_token_host="cloudfront"
    )
)
java
import software.amazon.awscdk.services.route53.*;


// Create the simple Origin
Bucket myBucket = new Bucket(this, "myBucket");
IOrigin s3Origin = S3BucketOrigin.withOriginAccessControl(myBucket, S3BucketOriginWithOACProps.builder()
        .originAccessLevels(List.of(AccessLevel.READ, AccessLevel.LIST))
        .build());

// Create the Distribution construct
Distribution myMultiTenantDistribution = Distribution.Builder.create(this, "cf-hosted-distribution")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(s3Origin)
                .build())
        .defaultRootObject("index.html")
        .build();

// Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
CfnDistribution cfnDistribution = (CfnDistribution)myMultiTenantDistribution.getNode().getDefaultChild();

DefaultCacheBehaviorProperty defaultCacheBehavior = DefaultCacheBehaviorProperty.builder()
        .targetOriginId(myBucket.getBucketArn())
        .viewerProtocolPolicy("allow-all")
        .compress(false)
        .allowedMethods(List.of("GET", "HEAD"))
        .cachePolicyId(CachePolicy.CACHING_OPTIMIZED.getCachePolicyId())
        .build();
// Create the updated distributionConfig
DistributionConfigProperty distributionConfig = DistributionConfigProperty.builder()
        .defaultCacheBehavior(defaultCacheBehavior)
        .enabled(true)
        // the properties below are optional
        .connectionMode("tenant-only")
        .origins(List.of(OriginProperty.builder()
                .id(myBucket.getBucketArn())
                .domainName(myBucket.getBucketDomainName())
                .s3OriginConfig(S3OriginConfigProperty.builder().build())
                .originPath("/{{tenantName}}")
                .build()))
        .tenantConfig(TenantConfigProperty.builder()
                .parameterDefinitions(List.of(ParameterDefinitionProperty.builder()
                        .definition(DefinitionProperty.builder()
                                .stringSchema(StringSchemaProperty.builder()
                                        .required(false)
                                        // the properties below are optional
                                        .comment("tenantName")
                                        .defaultValue("root")
                                        .build())
                                .build())
                        .name("tenantName")
                        .build()))
                .build())
        .build();

// Override the distribution configuration to enable multi-tenancy.
cfnDistribution.getDistributionConfig() = distributionConfig;

// Create a connection group and a cname record in an existing hosted zone to validate domain ownership
CfnConnectionGroup connectionGroup = CfnConnectionGroup.Builder.create(this, "cf-hosted-connection-group")
        .enabled(true)
        .ipv6Enabled(true)
        .name("my-connection-group")
        .build();

// Import the existing hosted zone info, replacing with your hostedZoneId and zoneName
String hostedZoneId = "YOUR_HOSTED_ZONE_ID";
String zoneName = "my.domain.com";
IHostedZone hostedZone = HostedZone.fromHostedZoneAttributes(this, "hosted-zone", HostedZoneAttributes.builder()
        .hostedZoneId(hostedZoneId)
        .zoneName(zoneName)
        .build());

CnameRecord record = CnameRecord.Builder.create(this, "cname-record")
        .domainName(connectionGroup.getAttrRoutingEndpoint())
        .zone(hostedZone)
        .recordName("cf-hosted-tenant.my.domain.com")
        .build();

// Create the cloudfront-hosted tenant, passing in the previously created connection group
CfnDistributionTenant cloudfrontHostedTenant = CfnDistributionTenant.Builder.create(this, "cf-hosted-tenant")
        .distributionId(myMultiTenantDistribution.getDistributionId())
        .name("cf-hosted-tenant")
        .domains(List.of("cf-hosted-tenant.my.domain.com"))
        .connectionGroupId(connectionGroup.getAttrId())
        .enabled(true)
        .managedCertificateRequest(ManagedCertificateRequestProperty.builder()
                .validationTokenHost("cloudfront")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Route53;


// Create the simple Origin
var myBucket = new Bucket(this, "myBucket");
var s3Origin = S3BucketOrigin.WithOriginAccessControl(myBucket, new S3BucketOriginWithOACProps {
    OriginAccessLevels = new [] { AccessLevel.READ, AccessLevel.LIST }
});

// Create the Distribution construct
var myMultiTenantDistribution = new Distribution(this, "cf-hosted-distribution", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = s3Origin
    },
    DefaultRootObject = "index.html"
});

// Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
var cfnDistribution = (CfnDistribution)myMultiTenantDistribution.Node.DefaultChild;

var defaultCacheBehavior = new DefaultCacheBehaviorProperty {
    TargetOriginId = myBucket.BucketArn,
    ViewerProtocolPolicy = "allow-all",
    Compress = false,
    AllowedMethods = new [] { "GET", "HEAD" },
    CachePolicyId = CachePolicy.CACHING_OPTIMIZED.CachePolicyId
};
// Create the updated distributionConfig
var distributionConfig = new DistributionConfigProperty {
    DefaultCacheBehavior = defaultCacheBehavior,
    Enabled = true,
    // the properties below are optional
    ConnectionMode = "tenant-only",
    Origins = new [] { new OriginProperty {
        Id = myBucket.BucketArn,
        DomainName = myBucket.BucketDomainName,
        S3OriginConfig = new S3OriginConfigProperty { },
        OriginPath = "/{{tenantName}}"
    } },
    TenantConfig = new TenantConfigProperty {
        ParameterDefinitions = new [] { new ParameterDefinitionProperty {
            Definition = new DefinitionProperty {
                StringSchema = new StringSchemaProperty {
                    Required = false,
                    // the properties below are optional
                    Comment = "tenantName",
                    DefaultValue = "root"
                }
            },
            Name = "tenantName"
        } }
    }
};

// Override the distribution configuration to enable multi-tenancy.
cfnDistribution.DistributionConfig = distributionConfig;

// Create a connection group and a cname record in an existing hosted zone to validate domain ownership
var connectionGroup = new CfnConnectionGroup(this, "cf-hosted-connection-group", new CfnConnectionGroupProps {
    Enabled = true,
    Ipv6Enabled = true,
    Name = "my-connection-group"
});

// Import the existing hosted zone info, replacing with your hostedZoneId and zoneName
var hostedZoneId = "YOUR_HOSTED_ZONE_ID";
var zoneName = "my.domain.com";
var hostedZone = HostedZone.FromHostedZoneAttributes(this, "hosted-zone", new HostedZoneAttributes {
    HostedZoneId = hostedZoneId,
    ZoneName = zoneName
});

var record = new CnameRecord(this, "cname-record", new CnameRecordProps {
    DomainName = connectionGroup.AttrRoutingEndpoint,
    Zone = hostedZone,
    RecordName = "cf-hosted-tenant.my.domain.com"
});

// Create the cloudfront-hosted tenant, passing in the previously created connection group
var cloudfrontHostedTenant = new CfnDistributionTenant(this, "cf-hosted-tenant", new CfnDistributionTenantProps {
    DistributionId = myMultiTenantDistribution.DistributionId,
    Name = "cf-hosted-tenant",
    Domains = new [] { "cf-hosted-tenant.my.domain.com" },
    ConnectionGroupId = connectionGroup.AttrId,
    Enabled = true,
    ManagedCertificateRequest = new ManagedCertificateRequestProperty {
        ValidationTokenHost = "cloudfront"
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"


// Create the simple Origin
myBucket := s3.NewBucket(this, jsii.String("myBucket"))
s3Origin := origins.S3BucketOrigin_WithOriginAccessControl(myBucket, &S3BucketOriginWithOACProps{
	OriginAccessLevels: []AccessLevel{
		cloudfront.AccessLevel_READ,
		cloudfront.AccessLevel_LIST,
	},
})

// Create the Distribution construct
myMultiTenantDistribution := cloudfront.NewDistribution(this, jsii.String("cf-hosted-distribution"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: s3Origin,
	},
	DefaultRootObject: jsii.String("index.html"),
})

// Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
cfnDistribution := myMultiTenantDistribution.Node.defaultChild.(CfnDistribution)

defaultCacheBehavior := &DefaultCacheBehaviorProperty{
	TargetOriginId: myBucket.bucketArn,
	ViewerProtocolPolicy: jsii.String("allow-all"),
	Compress: jsii.Boolean(false),
	AllowedMethods: []*string{
		jsii.String("GET"),
		jsii.String("HEAD"),
	},
	CachePolicyId: cloudfront.CachePolicy_CACHING_OPTIMIZED().CachePolicyId,
}
// Create the updated distributionConfig
distributionConfig := &DistributionConfigProperty{
	DefaultCacheBehavior: defaultCacheBehavior,
	Enabled: jsii.Boolean(true),
	// the properties below are optional
	ConnectionMode: jsii.String("tenant-only"),
	Origins: []interface{}{
		&OriginProperty{
			Id: myBucket.bucketArn,
			DomainName: myBucket.BucketDomainName,
			S3OriginConfig: &S3OriginConfigProperty{
			},
			OriginPath: jsii.String("/{{tenantName}}"),
		},
	},
	TenantConfig: &TenantConfigProperty{
		ParameterDefinitions: []interface{}{
			&ParameterDefinitionProperty{
				Definition: &DefinitionProperty{
					StringSchema: &StringSchemaProperty{
						Required: jsii.Boolean(false),
						// the properties below are optional
						Comment: jsii.String("tenantName"),
						DefaultValue: jsii.String("root"),
					},
				},
				Name: jsii.String("tenantName"),
			},
		},
	},
}

// Override the distribution configuration to enable multi-tenancy.
cfnDistribution.distributionConfig = distributionConfig

// Create a connection group and a cname record in an existing hosted zone to validate domain ownership
connectionGroup := cloudfront.NewCfnConnectionGroup(this, jsii.String("cf-hosted-connection-group"), &CfnConnectionGroupProps{
	Enabled: jsii.Boolean(true),
	Ipv6Enabled: jsii.Boolean(true),
	Name: jsii.String("my-connection-group"),
})

// Import the existing hosted zone info, replacing with your hostedZoneId and zoneName
hostedZoneId := "YOUR_HOSTED_ZONE_ID"
zoneName := "my.domain.com"
hostedZone := route53.HostedZone_FromHostedZoneAttributes(this, jsii.String("hosted-zone"), &HostedZoneAttributes{
	HostedZoneId: jsii.String(HostedZoneId),
	ZoneName: jsii.String(ZoneName),
})

record := route53.NewCnameRecord(this, jsii.String("cname-record"), &CnameRecordProps{
	DomainName: connectionGroup.attrRoutingEndpoint,
	Zone: hostedZone,
	RecordName: jsii.String("cf-hosted-tenant.my.domain.com"),
})

// Create the cloudfront-hosted tenant, passing in the previously created connection group
cloudfrontHostedTenant := cloudfront.NewCfnDistributionTenant(this, jsii.String("cf-hosted-tenant"), &CfnDistributionTenantProps{
	DistributionId: myMultiTenantDistribution.DistributionId,
	Name: jsii.String("cf-hosted-tenant"),
	Domains: []*string{
		jsii.String("cf-hosted-tenant.my.domain.com"),
	},
	ConnectionGroupId: connectionGroup.attrId,
	Enabled: jsii.Boolean(true),
	ManagedCertificateRequest: &ManagedCertificateRequestProperty{
		ValidationTokenHost: jsii.String("cloudfront"),
	},
})

Properties ​

anycastIpListIdoptionalstringanycast_ip_list_idoptionalstranycastIpListIdoptionalStringAnycastIpListIdoptionalstringAnycastIpListIdoptional*string #
The ID of the Anycast static IP list.
enabledoptionalboolean | IResolvableenabledoptionaltyping.Union[bool, IResolvable]enabledoptionalBooleanEnabledoptionalboolEnabledoptionalinterface{} #
Whether the connection group is enabled.
ipv6Enabledoptionalboolean | IResolvableipv6_enabledoptionaltyping.Union[bool, IResolvable]ipv6EnabledoptionalBooleanIpv6EnabledoptionalboolIpv6Enabledoptionalinterface{} #
IPv6 is enabled for the connection group.
namestringnamestrnameStringNamestringName*string required #
The name of the connection group.
tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag #
A complex type that contains zero or more `Tag` elements.