Skip to content
v2.278.0

CfnDistributionTenantProps Struct ​

Properties for defining a CfnDistributionTenant.

Example ​

ts
// 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 so we have access to the RoutingEndpoint associated with the tenant we are about to create
const connectionGroup = new cloudfront.CfnConnectionGroup(this, 'self-hosted-connection-group', {
    enabled: true,
    ipv6Enabled: true,
    name: 'self-hosted-connection-group',
});

// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
new CfnOutput(this, 'RoutingEndpoint', {
    value: connectionGroup.attrRoutingEndpoint,
    description: 'CloudFront Routing Endpoint to be added to my hosted zone CNAME records',
});

// Create a distribution tenant with a self-hosted domain.
const selfHostedTenant = new cloudfront.CfnDistributionTenant(this, 'self-hosted-tenant', {
    distributionId: myMultiTenantDistribution.distributionId,
    connectionGroupId: connectionGroup.attrId,
    name: 'self-hosted-tenant',
    domains: ['self-hosted-tenant.my.domain.com'],
    enabled: true,
    managedCertificateRequest: {
        primaryDomainName: 'self-hosted-tenant.my.domain.com',
        validationTokenHost: 'self-hosted',
    },
});
python
# 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 so we have access to the RoutingEndpoint associated with the tenant we are about to create
connection_group = cloudfront.CfnConnectionGroup(self, "self-hosted-connection-group",
    enabled=True,
    ipv6_enabled=True,
    name="self-hosted-connection-group"
)

# Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
CfnOutput(self, "RoutingEndpoint",
    value=connection_group.attr_routing_endpoint,
    description="CloudFront Routing Endpoint to be added to my hosted zone CNAME records"
)

# Create a distribution tenant with a self-hosted domain.
self_hosted_tenant = cloudfront.CfnDistributionTenant(self, "self-hosted-tenant",
    distribution_id=my_multi_tenant_distribution.distribution_id,
    connection_group_id=connection_group.attr_id,
    name="self-hosted-tenant",
    domains=["self-hosted-tenant.my.domain.com"],
    enabled=True,
    managed_certificate_request=cloudfront.CfnDistributionTenant.ManagedCertificateRequestProperty(
        primary_domain_name="self-hosted-tenant.my.domain.com",
        validation_token_host="self-hosted"
    )
)
java
// 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 so we have access to the RoutingEndpoint associated with the tenant we are about to create
CfnConnectionGroup connectionGroup = CfnConnectionGroup.Builder.create(this, "self-hosted-connection-group")
        .enabled(true)
        .ipv6Enabled(true)
        .name("self-hosted-connection-group")
        .build();

// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
CfnOutput.Builder.create(this, "RoutingEndpoint")
        .value(connectionGroup.getAttrRoutingEndpoint())
        .description("CloudFront Routing Endpoint to be added to my hosted zone CNAME records")
        .build();

// Create a distribution tenant with a self-hosted domain.
CfnDistributionTenant selfHostedTenant = CfnDistributionTenant.Builder.create(this, "self-hosted-tenant")
        .distributionId(myMultiTenantDistribution.getDistributionId())
        .connectionGroupId(connectionGroup.getAttrId())
        .name("self-hosted-tenant")
        .domains(List.of("self-hosted-tenant.my.domain.com"))
        .enabled(true)
        .managedCertificateRequest(ManagedCertificateRequestProperty.builder()
                .primaryDomainName("self-hosted-tenant.my.domain.com")
                .validationTokenHost("self-hosted")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// 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 so we have access to the RoutingEndpoint associated with the tenant we are about to create
var connectionGroup = new CfnConnectionGroup(this, "self-hosted-connection-group", new CfnConnectionGroupProps {
    Enabled = true,
    Ipv6Enabled = true,
    Name = "self-hosted-connection-group"
});

// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
new CfnOutput(this, "RoutingEndpoint", new CfnOutputProps {
    Value = connectionGroup.AttrRoutingEndpoint,
    Description = "CloudFront Routing Endpoint to be added to my hosted zone CNAME records"
});

// Create a distribution tenant with a self-hosted domain.
var selfHostedTenant = new CfnDistributionTenant(this, "self-hosted-tenant", new CfnDistributionTenantProps {
    DistributionId = myMultiTenantDistribution.DistributionId,
    ConnectionGroupId = connectionGroup.AttrId,
    Name = "self-hosted-tenant",
    Domains = new [] { "self-hosted-tenant.my.domain.com" },
    Enabled = true,
    ManagedCertificateRequest = new ManagedCertificateRequestProperty {
        PrimaryDomainName = "self-hosted-tenant.my.domain.com",
        ValidationTokenHost = "self-hosted"
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// 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 so we have access to the RoutingEndpoint associated with the tenant we are about to create
connectionGroup := cloudfront.NewCfnConnectionGroup(this, jsii.String("self-hosted-connection-group"), &CfnConnectionGroupProps{
	Enabled: jsii.Boolean(true),
	Ipv6Enabled: jsii.Boolean(true),
	Name: jsii.String("self-hosted-connection-group"),
})

// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
// Export the RoutingEndpoint, skip this step if you'd prefer to fetch it from the CloudFront console or via Cloudfront.ListConnectionGroups API
awscdk.NewCfnOutput(this, jsii.String("RoutingEndpoint"), &CfnOutputProps{
	Value: connectionGroup.attrRoutingEndpoint,
	Description: jsii.String("CloudFront Routing Endpoint to be added to my hosted zone CNAME records"),
})

// Create a distribution tenant with a self-hosted domain.
selfHostedTenant := cloudfront.NewCfnDistributionTenant(this, jsii.String("self-hosted-tenant"), &CfnDistributionTenantProps{
	DistributionId: myMultiTenantDistribution.DistributionId,
	ConnectionGroupId: connectionGroup.attrId,
	Name: jsii.String("self-hosted-tenant"),
	Domains: []*string{
		jsii.String("self-hosted-tenant.my.domain.com"),
	},
	Enabled: jsii.Boolean(true),
	ManagedCertificateRequest: &ManagedCertificateRequestProperty{
		PrimaryDomainName: jsii.String("self-hosted-tenant.my.domain.com"),
		ValidationTokenHost: jsii.String("self-hosted"),
	},
})

Properties ​

connectionGroupIdoptionalstringconnection_group_idoptionalstrconnectionGroupIdoptionalStringConnectionGroupIdoptionalstringConnectionGroupIdoptional*string #
The ID of the connection group for the distribution tenant.

If you don't specify a connection group, CloudFront uses the default connection group.

customizationsoptionalIResolvable | CfnDistributionTenant.CustomizationsPropertycustomizationsoptionaltyping.Union[IResolvable, CustomizationsProperty]customizationsoptionalIResolvableCustomizationsoptionalIResolvableCustomizationsoptionalinterface{} #
Customizations for the distribution tenant.
notes

For each distribution tenant, you can specify the geographic restrictions, and the Amazon Resource Names (ARNs) for the ACM certificate and AWS WAF web ACL. These are specific values that you can override or disable from the multi-tenant distribution that was used to create the distribution tenant.

distributionIdstringdistribution_idstrdistributionIdStringDistributionIdstringDistributionId*string required #
The ID of the multi-tenant distribution.
domainsstring[]domainstyping.List[str]domainsList<String>Domainsstring[]Domains*[]*string required #
The domains associated with the distribution tenant.
enabledoptionalboolean | IResolvableenabledoptionaltyping.Union[bool, IResolvable]enabledoptionalBooleanEnabledoptionalboolEnabledoptionalinterface{} #
Indicates whether the distribution tenant is in an enabled state.

If disabled, the distribution tenant won't serve traffic.

managedCertificateRequestoptionalIResolvable | CfnDistributionTenant.ManagedCertificateRequestPropertymanaged_certificate_requestoptionaltyping.Union[IResolvable, ManagedCertificateRequestProperty]managedCertificateRequestoptionalIResolvableManagedCertificateRequestoptionalIResolvableManagedCertificateRequestoptionalinterface{} #
An object that represents the request for the Amazon CloudFront managed ACM certificate.
namestringnamestrnameStringNamestringName*string required #
The name of the distribution tenant.
parametersoptionalIResolvable | IResolvable | CfnDistributionTenant.ParameterProperty[]parametersoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ParameterProperty]]]parametersoptionalIResolvableParametersoptionalIResolvableParametersoptionalinterface{} #
A list of parameter values to add to the resource.

A parameter is specified as a key-value pair. A valid parameter value must exist for any parameter that is marked as required in the multi-tenant distribution.

tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag #
A complex type that contains zero or more `Tag` elements.