Pulumiを使ってAWS ECS on AWS Fargateをやってみた
351日目
この記事はPulumi Advent Calendar 2019の15日目の記事です。
Pulumiに少し興味があったのでやってみました。 github.com
https://www.pulumi.com/docs/tutorials/aws/ecs-fargate/をほとんどそのままやっただけです。
VPCは自分で準備しました。
実行結果
$ pulumi up Previewing update (dev): Type Name Plan pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running. ├─ awsx:x:ecs:Cluster custom │ └─ awsx:x:ec2:SecurityGroup custom + │ ├─ awsx:x:ec2:IngressSecurityGroupRule custom-containers create + │ ├─ aws:ec2:SecurityGroup custom create + │ ├─ awsx:x:ec2:EgressSecurityGroupRule custom-egress create + │ ├─ awsx:x:ec2:EgressSecurityGroupRule custom-egress create + │ │ └─ aws:ec2:SecurityGroupRule custom-containers create + │ └─ awsx:x:ec2:IngressSecurityGroupRule custom-ssh create + │ └─ aws:ec2:SecurityGroupRule custom-ssh create ├─ awsx:x:ec2:Vpc sample │ ├─ awsx:x:ec2:Subnet public-2 + │ │ ├─ aws:ec2:Subnet public-2 create + │ │ ├─ aws:ec2:RouteTableAssociation public-2 create + │ │ └─ aws:ec2:Route public-2-ig create │ ├─ awsx:x:ec2:Subnet public-0 + │ │ ├─ aws:ec2:Subnet public-0 create + │ │ ├─ aws:ec2:RouteTableAssociation public-0 create + │ │ └─ aws:ec2:Route public-0-ig create │ └─ awsx:x:ec2:Subnet public-1 + │ ├─ aws:ec2:Subnet public-1 create + │ ├─ aws:ec2:RouteTableAssociation public-1 create + │ └─ aws:ec2:Route public-1-ig create ├─ awsx:lb:NetworkLoadBalancer nginx + │ ├─ aws:lb:LoadBalancer nginx create │ └─ awsx:lb:NetworkListener nginx + │ └─ aws:lb:Listener nginx create ├─ awsx:x:ecs:FargateTaskDefinition nginx + │ └─ aws:ecs:TaskDefinition nginx create └─ awsx:x:ecs:FargateService nginx + └─ aws:ecs:Service nginx create Outputs: + url: output<string> Resources: + 20 to create 28 unchanged Do you want to perform this update? yes Updating (dev): Type Name Status Info pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running.. ├─ awsx:x:ecs:FargateTaskDefinition nginx fe6a7a3b3f27: Layer already exists pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running │ └─ awsx:x:ec2:SecurityGroup custom pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running... pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running. pulumi:pulumi:Stack create_k8s_cluster_with_pulumi-dev running... + │ ├─ awsx:x:ec2:IngressSecurityGroupRule custom-containers created + │ │ └─ aws:ec2:SecurityGroupRule custom-containers creating + │ │ └─ aws:ec2:SecurityGroupRule custom-containers creating + │ │ └─ aws:ec2:SecurityGroupRule custom-containers creating.. ├─ awsx:x:ec2:Vpc sample │ ├─ awsx:x:ec2:Subnet public-2 + │ │ ├─ aws:ec2:Subnet public-2 created + │ │ ├─ aws:ec2:Subnet public-2 created + │ │ ├─ aws:ec2:Route public-2-ig created + │ │ └─ aws:ec2:RouteTableAssociation public-2 created ├─ awsx:x:ecs:FargateTaskDefinition nginx 1 warning + │ │ ├─ aws:ec2:Subnet public-0 created + │ │ ├─ aws:ec2:Route public-0-ig created + │ │ └─ aws:ec2:RouteTableAssociation public-0 created │ └─ awsx:x:ec2:Subnet public-1 + │ ├─ aws:ec2:Subnet public-1 created + │ ├─ aws:ec2:Route public-1-ig created + │ └─ aws:ec2:RouteTableAssociation public-1 created ├─ awsx:lb:NetworkLoadBalancer nginx + │ ├─ aws:lb:LoadBalancer nginx created │ └─ awsx:lb:NetworkListener nginx + │ └─ aws:lb:Listener nginx created └─ awsx:x:ecs:FargateService nginx + └─ aws:ecs:Service nginx created Diagnostics: awsx:x:ecs:FargateTaskDefinition (nginx): warning: WARNING! Your password will be stored unencrypted in /home/tsaeki/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Outputs: + url: "nginx-xxxxxxxx-207c5d174334e907.elb.ap-northeast-1.amazonaws.com" Resources: + 20 created 28 unchanged Duration: 5m26s
アクセスしてみます
$ curl http://$(pulumi stack output url) <html> <head> <title>Hello Fargate</title> </head> <body> <p>Hello AWS Fargate!</p> <p>Made with ❤️ with <a href="https://pulumi.com">Pulumi</a></p> </body> </html>