AWS CDK Cloudfront模块似乎运行不正常

时间:2019-10-24 02:48:03

标签: amazon-web-services aws-cdk

我使用如下所示的AWS cli,它可以正常工作。

  

aws cloudfront创建-分布-原始域名EcsTe-Farga-5AIKHC7TM127-1328201825.us-west-2.elb.amazonaws.com

我使用AWS CloudFormation,它也可以工作。

Resources:
  WebsiteCDN:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Enabled: 'true'
        DefaultCacheBehavior:
          ForwardedValues:
            QueryString: 'true'
          TargetOriginId: only-origin
          ViewerProtocolPolicy: allow-all
        Origins:
        - CustomOriginConfig:
            HTTPPort: '80'
            HTTPSPort: '443'
            OriginProtocolPolicy: http-only
          DomainName: 'EcsTe-Farga-5AIKHC7TM127-1328201825.us-west-2.elb.amazonaws.com'
          Id: only-origin

但是当我如下编写CDK代码时,它不起作用。我写错了什么代码吗?

  

export class Cf2 extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
            const distribution = new cloudfront.CloudFrontWebDistribution(this, 'SiteDistribution', {

              originConfigs: [
                  {
                      customOriginSource: {
                        domainName: 'EcsTe-Farga-5AIKHC7TM127-1328201825.us-west-2.elb.amazonaws.com'
                      },
                      behaviors: [{
                        isDefaultBehavior: true,
                        allowedMethods: cloudfront.CloudFrontAllowedMethods.ALL,
                      }]
                  }
              ]
          });
  }
}

0 个答案:

没有答案