@ossy/deployment-tools 0.0.75 → 0.0.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.75",
3
+ "version": "0.0.76",
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",
@@ -3,6 +3,7 @@
3
3
  * @typedef {Object} PlatformConfig
4
4
  * @property {string} platformName - Name of platform
5
5
  * @property {string} environmentType - local, test, qa, prod
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
8
9
  * @property {string=} awsRegion - ?
@@ -22,6 +22,7 @@ class DockerService {
22
22
  static createDockerNetworkForContainerManagerServer(platformConfig) {
23
23
  logInfo({ message: '[DockerService] Creating docker network for comunication between containers' })
24
24
  return exec(`docker network create ${platformConfig.ciDockerNetworkName}`)
25
+ .catch(() => {/* if it fils it's probably because the network already exists*/})
25
26
  }
26
27
 
27
28
  static stopContainer(deploymentRequest) {
@@ -1,17 +1,19 @@
1
1
  const { DockerService } = require('./docker-service')
2
2
 
3
- DockerService.deploy(
4
- { ciDockerNetworkName: 'deployment-tools' },
5
- {
6
- type: 'CONTAINER',
7
- dockerFile: './Dockerfile-prod',
8
- dockerContext: './',
9
- targetDeploymentPlatform: 'oskarssylwan',
10
- image: 'mongo',
11
- hostPort: '3005',
12
- containerPort: '3000',
13
- subdomain: 'cms',
14
- env: {},
15
- registry: 'ghcr.io'
16
- }
17
- )
3
+ // DockerService.deploy(
4
+ // { ciDockerNetworkName: 'deployment-tools' },
5
+ // {
6
+ // type: 'CONTAINER',
7
+ // dockerFile: './Dockerfile-prod',
8
+ // dockerContext: './',
9
+ // targetDeploymentPlatform: 'oskarssylwan',
10
+ // image: 'mongo',
11
+ // hostPort: '3005',
12
+ // containerPort: '3000',
13
+ // subdomain: 'cms',
14
+ // env: {},
15
+ // registry: 'ghcr.io'
16
+ // }
17
+ // )
18
+
19
+ DockerService.createDockerNetworkForContainerManagerServer({ ciDockerNetworkName: 'foo' })
@@ -1,5 +1,10 @@
1
- const { Stack } = require('aws-cdk-lib')
2
- const { HostedZone, ARecord, RecordTarget } = require('aws-cdk-lib/aws-route53')
1
+ const { Stack, Duration } = require('aws-cdk-lib')
2
+ const {
3
+ HostedZone,
4
+ ARecord,
5
+ MxRecord,
6
+ RecordTarget
7
+ } = require('aws-cdk-lib/aws-route53')
3
8
  const { SupportedDeploymentTypes, SupportedEnvironments } = require('../config')
4
9
  const { DeploymentTemplateService } = require('../template')
5
10
 
@@ -41,21 +46,45 @@ class DnsStack extends Stack {
41
46
  DeploymentTemplateService
42
47
  .groupDeploymentDomainsByRootDomain(containerDeployments)
43
48
  .forEach((domains, rootDomain) => {
44
- const hostedZone = new HostedZone(this, rootDomain, { zoneName: rootDomain })
49
+ const zone = new HostedZone(this, rootDomain, { zoneName: rootDomain })
45
50
 
46
51
  domains.forEach(domain => {
47
52
  new ARecord(this, domain, {
48
- zone: hostedZone,
53
+ zone,
49
54
  recordName: domain,
50
55
  target: RecordTarget.fromIpAddresses(props.containerDeploymentTargetPublicIp)
51
56
  })
52
57
  })
53
58
 
59
+ if (props.config.dnsRecords && props.config.dnsRecords[rootDomain]) {
60
+ const records = props.config.dnsRecords[rootDomain] || []
61
+
62
+ records.forEach(({ type, ttl, recordName, values }) => {
63
+ switch (type) {
64
+
65
+ case 'MX':
66
+ new MxRecord(
67
+ this,
68
+ `${recordName}-MX-Record`,
69
+ { type, recordName, values, ttl: Duration.seconds(ttl), zone }
70
+ )
71
+ break
72
+
73
+ default:
74
+ throw new Error(`Unsupported record type: ${type}`)
75
+ }
76
+ })
77
+ }
78
+
54
79
  })
55
80
 
56
81
  }
57
82
  }
58
83
 
84
+ function createDnsRecords(zone, records) {
85
+
86
+ }
87
+
59
88
  module.exports = {
60
89
  DnsStack
61
90
  }
@@ -33,8 +33,10 @@ class TrustCiStack extends Stack {
33
33
  const GitHubPrincipal = new OpenIdConnectPrincipal(provider)
34
34
  .withConditions({
35
35
  StringLike: {
36
- 'token.actions.githubusercontent.com:sub':
37
- `repo:${props.config.ciGithubActionsRepo}:*`
36
+ 'token.actions.githubusercontent.com:sub': `repo:${props.config.ciGithubActionsRepo}:*`
37
+ },
38
+ StringEquals: {
39
+ 'token.actions.githubusercontent.com:aud': 'sts.amazonaws.com'
38
40
  }
39
41
  })
40
42