aws_cloudfront.CustomOriginConfig not working in Python
See original GitHub issueI am facing a issue with using aws_cloudfront.CustomOriginConfig in Python. I know this class is still at experimental release, but I would greatly appreciate any help/comments that may resolve my issue.
Reproduction Steps
I am trying to set up a CloudFront distribution with two origins, S3 and API Gateway. Below is the code snippet to prepare the distribution.
import aws_cloudfront as cfront
...
# define cloudfront distribution
distribution = cfront.CloudFrontWebDistribution(
self, "CloudFrontDistribution",
origin_configs=[
cfront.SourceConfiguration(
s3_origin_source=cfront.S3OriginConfig(
s3_bucket_source=site_bucket,
origin_access_identity_id=props.oia.ref
),
behaviors=[cfront.Behavior(is_default_behavior=True)],
),
cfront.SourceConfiguration(
custom_origin_source=cfront.CustomOriginConfig(
domain_name=props.apigw_domain_name
),
behaviors=[cfront.Behavior(
allowed_methods=cfront.CloudFrontAllowedMethods.ALL,
path_pattern="/api"
)]
)
],
)
Error Log
Here is the error message I got when I ran cdk synth
.
jsii.errors.JSIIError: Got ‘undefined’ for non-optional instance of {“abstract”:true,“docs”:{“remarks”:“Should not include the path - that should be in the parent SourceConfiguration”,“stability”:“experimental”,“summary”:“The domain name of the custom origin.”},“immutable”:true,“locationInModule”:{“filename”:“lib/web_distribution.ts”,“line”:179},“name”:“domainName”,“type”:{“primitive”:“string”}}
If I delete the CustomOriginConfig
part (i.e. only with S3 origin), the build succeeds.
I am thinking that this may be a bug in the CDK. Or, am I using the functions in a wrong way?
Environment
- **CLI Version : CDK v1.15
- Framework Version:
- **OS : Ubuntu 16.04 LTS
- **Language : Python 3.7
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
@tomomano
api.domainName
refers to aDomainName
object which is relevant when using custom domains.This property may be null in case your APIGW does not have a custom domain. If it’s not null (which seems to be the case), and you want the actual domain name, you will need to use the
api.domain_name.domain_name
property.Please reopen if this doesn’t help resolve the issue.
ok - figured it out :