-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1186 from alliance-genome/SCRUM-3289
Added code for deploing a ALB with the UI code
- Loading branch information
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,6 @@ Thumbs.db | |
*.swp | ||
|
||
|
||
cdk-outputs.json | ||
cdk.context.json | ||
cdk.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts cdk/cdk-stage.ts", | ||
"context": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from 'aws-cdk-lib'; | ||
import {StageALBStack} from './stage-alb-stack'; | ||
|
||
const app = new cdk.App(); | ||
|
||
new StageALBStack(app, 'stage-alb-stack', { | ||
stackName: 'stage-alb-stack', | ||
env: { | ||
region: process.env.CDK_DEFAULT_REGION, | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling'; | ||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import * as route53 from 'aws-cdk-lib/aws-route53'; | ||
import * as route53Targets from 'aws-cdk-lib/aws-route53-targets'; | ||
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2'; | ||
import * as targets from 'aws-cdk-lib/aws-elasticloadbalancingv2-targets'; | ||
import * as cdk from 'aws-cdk-lib'; | ||
|
||
export class StageALBStack extends cdk.Stack { | ||
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
|
||
const vpc = ec2.Vpc.fromLookup(this, 'Docker', { vpcName: 'Docker' }); | ||
const sg1 = ec2.SecurityGroup.fromLookupById(this, 'default', 'sg-21ac675b'); | ||
const sg2 = ec2.SecurityGroup.fromLookupById(this, 'HTTP/HTTPS', 'sg-0415cab61ab6b45c5'); | ||
const cert = elbv2.ListenerCertificate.fromArn('arn:aws:acm:us-east-1:100225593120:certificate/047a56a2-09dd-4857-9f28-32d23650d4da'); | ||
const stage = new targets.InstanceIdTarget('i-0d7ea7b7cc11a2e8f') | ||
const public_zone = route53.HostedZone.fromHostedZoneAttributes(this, 'Public Zone', { zoneName: 'alliancegenome.org', hostedZoneId: 'Z3IZ3D6V94JEC2' }); | ||
const private_zone = route53.HostedZone.fromHostedZoneAttributes(this, 'Private Zone', { zoneName: 'alliancegenome.org', hostedZoneId: 'Z007692222A6W93AZVSPD' }); | ||
|
||
const alb = new elbv2.ApplicationLoadBalancer(this, 'alb', { | ||
vpc, | ||
internetFacing: true, | ||
securityGroup: sg1 | ||
}); | ||
|
||
alb.addSecurityGroup(sg2); | ||
|
||
new route53.CnameRecord(this, "Public DNS", { | ||
zone: public_zone, | ||
recordName: "stage-alb", | ||
domainName: alb.loadBalancerDnsName, | ||
ttl: cdk.Duration.minutes(5) | ||
}); | ||
new route53.CnameRecord(this, "Private DNS", { | ||
zone: private_zone, | ||
recordName: "stage-alb", | ||
domainName: alb.loadBalancerDnsName, | ||
ttl: cdk.Duration.minutes(5) | ||
}); | ||
|
||
const listener_https = alb.addListener('HTTPS Listener', { | ||
port: 443, | ||
open: true, | ||
certificates: [cert] | ||
}); | ||
|
||
listener_https.addTargets("Backend Stage", { | ||
healthCheck: { | ||
path: '/robots.txt', | ||
unhealthyThresholdCount: 3, | ||
healthyThresholdCount: 5, | ||
interval: cdk.Duration.seconds(60), | ||
}, | ||
port: 80, | ||
targets: [stage], | ||
}); | ||
|
||
/* | ||
listener_https.addAction("Redirect to Stage", { | ||
priority: 10, | ||
conditions: [ | ||
elbv2.ListenerCondition.hostHeaders(['stage-alb.alliancegenome.org']), | ||
], | ||
action: elbv2.ListenerAction.redirect({ | ||
protocol: 'HTTPS', | ||
port: '443', | ||
host: 'stage.alliancegenome.org', | ||
path: '/#{path}', | ||
query: '#{query}', | ||
permanent: true, | ||
}), | ||
}); | ||
*/ | ||
|
||
const listener_http = alb.addListener('HTTP Listener', { | ||
port: 80, | ||
open: true, | ||
defaultAction: elbv2.ListenerAction.redirect({ | ||
protocol: 'HTTPS', | ||
port: '443', | ||
host: 'stage.alliancegenome.org', | ||
path: '/#{path}', | ||
query: '#{query}', | ||
permanent: true, | ||
}), | ||
}); | ||
|
||
new cdk.CfnOutput(this, 'albDNS', { | ||
value: alb.loadBalancerDnsName | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "commonjs", | ||
"lib": ["es2018", "ESNext.AsyncIterable"], | ||
"allowJs": true, | ||
"checkJs": true, | ||
"removeComments": true, | ||
"resolveJsonModule": true, | ||
"declaration": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"typeRoots": ["./node_modules/@types"], | ||
"isolatedModules": true | ||
}, | ||
"exclude": ["node_modules", "**/node_modules/*", "cdk.out"] | ||
} |