亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“SiteCertificate”對象在 AWS CDK 中沒有屬性

“SiteCertificate”對象在 AWS CDK 中沒有屬性

慕雪6442864 2022-08-16 18:16:58
我正在嘗試將 CloudFormation 項目遷移到 AWS CDK。我從前端開始,這是一個靜態站點,在具有證書管理器證書的 S3 存儲桶前面使用 CloudFront 分配。以下是我用來構建此堆棧的各種組件:根from aws_cdk import corefrom cert import SiteCertificatefrom hosted_zone import HostedZonefrom static_site import StaticSiteclass AwscdkStack(core.Stack):    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:        super().__init__(scope, id, **kwargs)        self.hosted_zone = HostedZone(self, "HostedZone")        self.certificate = SiteCertificate(self, "SiteCert")        self.static_site = StaticSite(            self, 'StaticSite',            hosted_zone=self.hosted_zone,            certificate=self.certificate        )托管區域import osfrom aws_cdk import (    core,    aws_route53 as route53)class HostedZone(core.Construct):    def __init__(self, scope: core.Construct, id: str, **kwargs):        super().__init__(scope, id, **kwargs)        self.hosted_zone = route53.HostedZone.from_hosted_zone_attributes(            self, "hosted_zone",            hosted_zone_id=os.environ.get("HOSTED_ZONE_ID", "ABC123"),            zone_name=os.environ.get("DOMAIN_NAME", "mysite.com")        )證書import osfrom aws_cdk import (    core,    aws_certificatemanager as acm,)class SiteCertificate(core.Construct):    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:        super().__init__(scope, id, **kwargs)        cert = acm.Certificate(            self, "SiteCertificate",            domain_name=f"*.{os.environ.get('DOMAIN_NAME', 'mysite.com')}"        )
查看完整描述

1 回答

?
婷婷同學_

TA貢獻1844條經驗 獲得超8個贊

這看起來您缺少屬性定義SiteCertificate


        self.certificate = SiteCertificate(self, "SiteCert")


        self.static_site = StaticSite(

            self, 'StaticSite',

            hosted_zone=self.hosted_zone,

            certificate=self.certificate

        )

在 StaticSite 中引用,但 SiteCertificate 沒有定義該屬性。certificate.certificate_arn


class SiteCertificate(core.Construct):


    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:

        super().__init__(scope, id, **kwargs)


        cert = acm.Certificate(

            self, "SiteCertificate",

            domain_name=f"*.{os.environ.get('DOMAIN_NAME', 'mysite.com')}"

        )

        // Add this

        self.certificate_arn = cert.certificate_arn

或者從 acm 繼承。CeritificateSiteCertificate


class SiteCertificate(acm.Certificate):


    def __init__(self, scope: core.Construct) -> None:

        super().__init__(scope, "SiteCertificate",

            domain_name=f"*.{os.environ.get('DOMAIN_NAME', 'mysite.com')}")

我不是Python專家,所以我可能錯過了一些東西。


查看完整回答
反對 回復 2022-08-16
  • 1 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號