examples icon indicating copy to clipboard operation
examples copied to clipboard

Https Server Example

Open pmantica3 opened this issue 2 years ago • 2 comments

Hello!

Hi I would like to request a pulumi example to create an https server on AWS. I saw there are examples for http, but couldn't find one for https.

Also, thanks for the amazing product. I love being able to run pulumi in python instead of a DSL.

pmantica3 avatar Sep 08 '22 02:09 pmantica3

@pmantica3 Thanks for the suggestion (and for the kind words, too!). What sort of server did you have in mind? Like a standard web server like Nginx or Apache running on a virtual machine? Or more like an app server or cloud service?

cnunciato avatar Sep 08 '22 14:09 cnunciato

Thanks for responding so quickly! I am personally interested in setting up a https for a AWS EKS service. I haven't been able to finish/test this code, but I think that based on the AWS documentation. It should look like something like this: https://aws.amazon.com/premiumsupport/knowledge-center/terminate-https-traffic-eks-acm/

cert = aws.acm.Certificate(
    "cert", domain_name="example.com", validation_method="DNS"
)


monitoring_service = k8s.core.v1.Service(
    f"{app_name}-monitoring-service",
    metadata=k8s.meta.v1.ObjectMetaArgs(
        annotations={
            "service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http",
            "service.beta.kubernetes.io/aws-load-balancer-ssl-cert": <cert.arn>,
            "service.beta.kubernetes.io/aws-load-balancer-ssl-ports": "https",
        }
    ),
    spec=k8s.core.v1.ServiceSpecArgs(
        type="LoadBalancer",
        selector=app_labels,
        ports=[k8s.core.v1.ServicePortArgs(port=80), k8s.core.v1.ServicePortArgs(port=443)],
    ),
)

pmantica3 avatar Sep 08 '22 15:09 pmantica3