-
Notifications
You must be signed in to change notification settings - Fork 880
/
index.js
43 lines (36 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2016-2023, Pulumi Corporation. All rights reserved.
const aws = require("@pulumi/aws");
const awsx = require("@pulumi/awsx");
const pulumi = require("@pulumi/pulumi");
// An ECS cluster to deploy into.
const cluster = new aws.ecs.Cluster("cluster", {});
// An ALB to serve the container endpoint to the internet.
const loadbalancer = new awsx.lb.ApplicationLoadBalancer("loadbalancer", {});
// An ECR repository to store our application's container image.
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});
// Build and publish our application's container image from ./app to the ECR repository.
const image = new awsx.ecr.Image("image", {
repositoryUrl: repo.url,
context: "./app",
});
// Deploy an ECS Service on Fargate to host the application container.
const service = new awsx.ecs.FargateService("service", {
cluster: cluster.arn,
assignPublicIp: true,
taskDefinitionArgs: {
container: {
image: image.imageUri,
cpu: 128,
memory: 512,
essential: true,
portMappings: [{
containerPort: 80,
targetGroup: loadbalancer.defaultTargetGroup,
}],
},
},
});
// The URL at which the container's HTTP endpoint will be available.
exports.frontendURL = pulumi.interpolate`http://${loadbalancer.loadBalancer.dnsName}`;