Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何在loadbalancer中生成ListnerCertificate_Amazon Web Services_Certificate_Ssl Certificate_Amazon Cloudformation_Troposphere - Fatal编程技术网

Amazon web services 如何在loadbalancer中生成ListnerCertificate

Amazon web services 如何在loadbalancer中生成ListnerCertificate,amazon-web-services,certificate,ssl-certificate,amazon-cloudformation,troposphere,Amazon Web Services,Certificate,Ssl Certificate,Amazon Cloudformation,Troposphere,我想在ApplicationLoadBalancer的listner中添加certificate。如何添加以及如何相互关联,我正在使用HTTPS协议来设置/配置sslcertificate Listener = t.add_resource(elb.Listener( "Listener", Certificates=elb.Certificate( CertificateArn="", ), Port="443", Protocol="H

我想在
ApplicationLoadBalancer
listner
中添加
certificate
。如何添加以及如何相互关联,我正在使用
HTTPS
协议来设置/配置sslcertificate

Listener = t.add_resource(elb.Listener(
    "Listener",
    Certificates=elb.Certificate(
        CertificateArn="",
    ),
    Port="443",
    Protocol="HTTPS",
    LoadBalancerArn=Ref(ApplicationLoadBalancer),
    SslPolicy="ELBSecurityPolicy-TLS-1-2-Ext-2018-06",
    DefaultActions=[elb.Action(
        Type="forward",
        TargetGroupArn=Ref(TargetGroupApp)
    )]
))

ListenerCertificate = t.add_resource(elb.ListenerCertificate(
    "ListenerCertificate",
    Certificates=elb.Certificate(
            CertificateArn="",
            ),
    ListenerArn=Ref(Listener)
    ))

如何在listner和listnercertificate中添加
certificate

有两种方法可以将现有证书添加到侦听器中-您已经列出了这两种方法,但实际上只需要其中一种。另外,我假设您需要创建证书。这显示了附加证书的方式,也显示了附加证书的两种方式。需要记住的一点是,即使在CloudFormation中创建了证书,也有一个手动步骤来批准证书创建,因此您需要关注电子邮件中的批准请求:

from troposphere.certificatemanager import Certificate
# First create the certificate if it doesn't already exist

cert = t.add_resource(
    Certificate(
        "MyCert",
        DomainName="example.com",
    )
)

# Now you can add it to the load balancer directly/inline
Listener = t.add_resource(elb.Listener(
    "Listener",
    Certificates=elb.Certificate(
        CertificateArn=cert.Ref(),
    ),
    Port="443",
    Protocol="HTTPS",
    LoadBalancerArn=Ref(ApplicationLoadBalancer),
    SslPolicy="ELBSecurityPolicy-TLS-1-2-Ext-2018-06",
    DefaultActions=[elb.Action(
        Type="forward",
        TargetGroupArn=Ref(TargetGroupApp)
    )]
))


# Or you can add it to an existing Listener with this resource
ListenerCertificate = t.add_resource(elb.ListenerCertificate(
    "ListenerCertificate",
    Certificates=elb.Certificate(
            CertificateArn=cert.Ref(),
            ),
    ListenerArn=Ref(Listener)
    ))
如果您已经有一个证书,那么您不需要第一步创建它-只需提供arn(您可以在仪表板中找到它)作为参数,而不是
cert.Ref()


希望有帮助。

是的,我还没有创建任何
证书
我必须先创建一个。关于hear,
ertificate=t.add_resource(elb.Certificate('Certificate',DomainName='x.x.com',DomainValidationOptions=[DomainValidationOption(DomainName='x.x.com',ValidationDomain='x.x.com',),],Tags=[{'Key':'tag Key','Value':'tag Value'},],)
我应该使用哪种方式?我不确定您现在遇到了什么问题?你能解释一下让你困惑的是什么吗?在上面的示例中,我给出了一个使用certificatemanager证书创建证书的示例。证书不是资源,它是将elb链接到已创建证书的属性。您也可以在示例中看到我对它的使用,这里:``Certificates=elb.Certificate(CertificateArn=cert.Ref(),),``耶!这已经奏效了——但它的状态仍然是
待定验证
我们还需要从我的原始帖子中添加或说明什么吗:记住一件事——批准证书创建有一个手动步骤,即使它是在CloudFormation中创建的,因此,您需要关注电子邮件中的批准请求基本上您必须手动批准证书,通常通过电子邮件进行。我认为您也可以通过证书管理器门户实现这一点,但我不确定。