-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsolar-system.ts
52 lines (47 loc) · 1.57 KB
/
solar-system.ts
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
44
45
46
47
48
49
50
51
52
import { Repository } from '@aws-cdk/aws-ecr';
import { ContainerImage } from '@aws-cdk/aws-ecs';
import { SolarSystemExtensionStack, SolarSystemExtensionStackProps } from '@cdk-cosmos/core';
import { SsmState } from '@cosmos-building-blocks/common';
import { EcsService } from '@cosmos-building-blocks/service';
import { AppGalaxyStack } from '.';
export interface AppSolarSystemProps extends SolarSystemExtensionStackProps {
appVersion?: string;
}
export class AppSolarSystemStack extends SolarSystemExtensionStack {
readonly galaxy: AppGalaxyStack;
constructor(galaxy: AppGalaxyStack, id: string, props?: AppSolarSystemProps) {
super(galaxy, id, {
portalProps: {
vpcProps: {
aZsLookup: true,
},
},
...props
});
const { appVersion } = props || {};
const { ecrRepo } = this.galaxy.cosmos;
const { vpc } = this.portal;
const { cluster, httpListener, httpsListener } = this.portal.addEcs();
const ecrRepoClone = Repository.fromRepositoryAttributes(this, 'EcrRepo', ecrRepo); // Scope issue
const versionState = new SsmState(this, 'VersionState', {
name: '/' + this.nodeId('VersionState', '/'),
value: appVersion,
});
new EcsService(this, 'Frontend', {
vpc,
cluster,
httpListener,
httpsListener,
containerProps: {
image: ContainerImage.fromEcrRepository(ecrRepoClone, versionState.value),
port: {
containerPort: 3000,
},
},
routingProps: {
pathPattern: '/demo',
httpsRedirect: true,
},
});
}
}