@ossy/deployment-tools 0.0.92 → 0.0.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/caddy/caddy.js +1 -1
- package/src/config/platform-config.js +1 -0
- package/src/docker/docker-service.js +1 -0
- package/src/infrastructure/cli.js +5 -2
- package/src/infrastructure/container-deployment-target/container-deployment-target.js +2 -2
- package/src/infrastructure/deployment-target-stack.js +4 -6
- package/src/infrastructure/ses-stack.js +41 -0
package/README.md
CHANGED
|
@@ -73,6 +73,12 @@ journalctl -u deployment-tools.service -n 200 -f
|
|
|
73
73
|
journalctl -u caddy-route53.service -n 200 -f
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
**View logs from docker service**
|
|
77
|
+
```
|
|
78
|
+
// With last 200 lines and follow new logs
|
|
79
|
+
journalctl -u docker.service -n 200 -f
|
|
80
|
+
```
|
|
81
|
+
|
|
76
82
|
**Upgrade deployment-tools server version**
|
|
77
83
|
|
|
78
84
|
- 1 release new version of the npm package with `npm publish`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/deployment-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.93",
|
|
4
4
|
"description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/caddy/caddy.js
CHANGED
|
@@ -98,7 +98,7 @@ class CaddyService {
|
|
|
98
98
|
logInfo({ message: `[CaddyService] Replacing proxy for ${containerDeploymentTemplate.domain}` })
|
|
99
99
|
const proxyConfig = CaddyConfigService.createProxyConfig(containerDeploymentTemplate)
|
|
100
100
|
return fetch(`http://localhost:2019/id/${containerDeploymentTemplate.domain}`, {
|
|
101
|
-
method: '
|
|
101
|
+
method: 'PUT',
|
|
102
102
|
headers: { 'Content-Type': 'application/json' },
|
|
103
103
|
body: JSON.stringify(proxyConfig)
|
|
104
104
|
})
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Platform config definition
|
|
3
3
|
* @typedef {Object} PlatformConfig
|
|
4
4
|
* @property {string} platformName - Name of platform
|
|
5
|
+
* @property {string[]=} sesDomains - list of domains to configure AWS SES email identity and DKIM records for
|
|
5
6
|
* @property {object} dnsRecords - map of dns records by root domain, only supports MX records so that we can add dns records for our email service
|
|
6
7
|
*
|
|
7
8
|
* @property {string} awsAccountId - Aws account id
|
|
@@ -48,6 +48,7 @@ class DockerService {
|
|
|
48
48
|
.catch(() => {
|
|
49
49
|
logError({ message: `[DockerService] Faild to remove image for ${deploymentRequest.domain}` })
|
|
50
50
|
}) // no worries if container isn't there
|
|
51
|
+
.then(() => exec(`docker rm -f c-${name}`))
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
static pullImage({ image, registry }) {
|
|
@@ -4,13 +4,14 @@ const { App } = require('aws-cdk-lib')
|
|
|
4
4
|
const { TrustCiStack } = require('./trust-ci-stack')
|
|
5
5
|
const { DeploymentTargetStack } = require('./deployment-target-stack')
|
|
6
6
|
const { DnsStack } = require('./dns-stack')
|
|
7
|
+
const { SesStack } = require('./ses-stack')
|
|
7
8
|
const { PlatformTemplateService, DeploymentTemplateService } = require('../template')
|
|
8
9
|
const { PlatformConfigService } = require('../config')
|
|
9
10
|
|
|
10
11
|
Promise.all([
|
|
11
|
-
DeploymentTemplateService.readFromFiles(
|
|
12
|
+
DeploymentTemplateService.readFromFiles('../infrastructure/deployments.json'),
|
|
12
13
|
PlatformTemplateService
|
|
13
|
-
.readFromFile(
|
|
14
|
+
.readFromFile('../infrastructure/platforms.json')
|
|
14
15
|
.then(templates => templates.map(PlatformConfigService.from))
|
|
15
16
|
])
|
|
16
17
|
.then(([deploymentMap, configs]) => {
|
|
@@ -36,5 +37,7 @@ Promise.all([
|
|
|
36
37
|
containerDeploymentTargetPublicIp: deploymentTarget.containerDeploymentTargetPublicIp
|
|
37
38
|
})
|
|
38
39
|
|
|
40
|
+
new SesStack(app, `${config.platformName}-ses`, stackProps)
|
|
41
|
+
|
|
39
42
|
})
|
|
40
43
|
})
|
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
Peer,
|
|
12
12
|
Port,
|
|
13
13
|
UserData,
|
|
14
|
-
|
|
14
|
+
KeyPair,
|
|
15
15
|
BlockDeviceVolume
|
|
16
16
|
} = require('aws-cdk-lib/aws-ec2')
|
|
17
17
|
const { Role, ServicePrincipal, Policy, PolicyStatement, Effect } = require('aws-cdk-lib/aws-iam')
|
|
@@ -156,7 +156,7 @@ class ContainerDeploymentTarget extends Construct {
|
|
|
156
156
|
volume: BlockDeviceVolume.ebs(50)
|
|
157
157
|
}
|
|
158
158
|
],
|
|
159
|
-
|
|
159
|
+
keyPair: KeyPair.fromKeyPairName(this, 'KeyPair', props.config.awsKeyPairName)
|
|
160
160
|
})
|
|
161
161
|
|
|
162
162
|
props.bucket.grantRead(ec2Instance, '*')
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-new */
|
|
2
2
|
const { nanoid } = require('nanoid')
|
|
3
|
-
const { CfnOutput, Stack,
|
|
4
|
-
const {
|
|
5
|
-
const { Bucket, BucketEncryption, BlockPublicAccess } = require('aws-cdk-lib/aws-s3')
|
|
3
|
+
const { CfnOutput, Stack, RemovalPolicy } = require('aws-cdk-lib')
|
|
4
|
+
const { Bucket, BlockPublicAccess } = require('aws-cdk-lib/aws-s3')
|
|
6
5
|
const { Distribution, PriceClass } = require('aws-cdk-lib/aws-cloudfront')
|
|
7
|
-
const {
|
|
6
|
+
const { S3BucketOrigin, } = require('aws-cdk-lib/aws-cloudfront-origins')
|
|
8
7
|
const { ContainerDeploymentTarget } = require('./container-deployment-target')
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -29,7 +28,6 @@ class DeploymentTargetStack extends Stack {
|
|
|
29
28
|
new Bucket(this, 'StaticDeploymentTarget', {
|
|
30
29
|
bucketName: props.config.awsStaticBucketName,
|
|
31
30
|
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
|
|
32
|
-
encryption: BucketEncryption.UNENCRYPTED,
|
|
33
31
|
removalPolicy: RemovalPolicy.RETAIN,
|
|
34
32
|
autoDeleteObjects: false,
|
|
35
33
|
cors: [{
|
|
@@ -42,7 +40,7 @@ class DeploymentTargetStack extends Stack {
|
|
|
42
40
|
|
|
43
41
|
const mediaCDN = new Distribution(this, 'Media', {
|
|
44
42
|
defaultBehavior: {
|
|
45
|
-
origin:
|
|
43
|
+
origin: S3BucketOrigin.withOriginAccessControl(staticDeploymentTarget, { originPath: '/media' })
|
|
46
44
|
},
|
|
47
45
|
priceClass: PriceClass.PRICE_CLASS_100
|
|
48
46
|
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable no-new */
|
|
2
|
+
const { Stack } = require('aws-cdk-lib')
|
|
3
|
+
const { HostedZone } = require('aws-cdk-lib/aws-route53')
|
|
4
|
+
const { EmailIdentity, Identity } = require('aws-cdk-lib/aws-ses')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SesStackProps
|
|
8
|
+
* @typedef {Object} SesStackProps
|
|
9
|
+
* @property {PlatformConfig} config - platform config
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates SES email identities for each domain in config.sesDomains and
|
|
14
|
+
* automatically adds the required DKIM CNAME records to the Route53 hosted zone.
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
class SesStack extends Stack {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} scope
|
|
21
|
+
* @param {string} id
|
|
22
|
+
* @param {SesStackProps} props
|
|
23
|
+
*/
|
|
24
|
+
constructor(scope, id, props) {
|
|
25
|
+
super(scope, id, props)
|
|
26
|
+
|
|
27
|
+
const domains = props.config.sesDomains || []
|
|
28
|
+
|
|
29
|
+
domains.forEach(domain => {
|
|
30
|
+
const zone = HostedZone.fromLookup(this, `${domain}-ses-zone`, { domainName: domain })
|
|
31
|
+
|
|
32
|
+
new EmailIdentity(this, `${domain}-ses-identity`, {
|
|
33
|
+
identity: Identity.publicHostedZone(zone),
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
SesStack
|
|
41
|
+
}
|