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'
},
});
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.
The name of the connection group.