Skip to content

Commit

Permalink
feat: add ecr and ecs config
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin9foong committed Dec 6, 2024
1 parent 0f579c8 commit 3d71c63
Show file tree
Hide file tree
Showing 10 changed files with 4,625 additions and 3,901 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
/bin/
/node_modules/
2 changes: 2 additions & 0 deletions Pulumi.staging-alt3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config:
aws:region: ap-southeast-1
10 changes: 10 additions & 0 deletions Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: formsg-infra
runtime:
name: nodejs
options:
packagemanager: npm
description: pulumi config for formsg
config:
pulumi:tags:
value:
pulumi:template: aws-typescript
1 change: 0 additions & 1 deletion README.md

This file was deleted.

13 changes: 13 additions & 0 deletions ecr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as awsx from "@pulumi/awsx";

// ECR Repository used to store the Docker images built by the CI/CD pipeline on Staging-alt3 branch
const formsg_staging_alt3_repo = new awsx.ecr.Repository("formsg/staging-alt3");

// Build the staging-alt3 image and push it to the ECR repository
const staging_alt3_image = new awsx.ecr.Image("staging-alt3-image", {
repositoryUrl: formsg_staging_alt3_repo.url,
platform: "linux/amd64",
context: './app'
})

export const staging_alt3_image_uri = staging_alt3_image.imageUri;
31 changes: 31 additions & 0 deletions ecs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as awsx from "@pulumi/awsx";
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
import { staging_alt3_image_uri } from "./ecr";

// Required to access container over port 80 using a stable IP address
const lb = new awsx.lb.ApplicationLoadBalancer("formsg-staging-alt3-lb");

const cluster = new aws.ecs.Cluster("formsg-staging-alt3-cluster");

const service = new awsx.ecs.FargateService("formsg-staging-alt3-service", {
cluster: cluster.arn,
desiredCount: 1,
assignPublicIp: true,
taskDefinitionArgs: {
container: {
name: "formsg_staging_alt3",
image: staging_alt3_image_uri,
essential: true,
cpu: 128,
memory: 512,
portMappings: [{
containerPort: 80,
targetGroup: lb.defaultTargetGroup
}]
}
}
});

// uri to access the staging-alt3 service
export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`;
7 changes: 2 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
import {} from '@opengovsg/pulumi-components'
import * as aws from '@pulumi/aws'
import * as pulumi from '@pulumi/pulumi'

// Config goes here...
import * as ecs from "./ecs";
import * as ecr from "./ecr";
Loading

0 comments on commit 3d71c63

Please sign in to comment.