@ossy/deployment-tools 0.0.32 → 0.0.34
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,8 +1,7 @@
|
|
|
1
1
|
import * as core from '@actions/core'
|
|
2
2
|
import { STSClient, AssumeRoleWithWebIdentityCommand } from '@aws-sdk/client-sts'
|
|
3
3
|
import { DeploymentPlatform } from 'types'
|
|
4
|
-
import {
|
|
5
|
-
import { Credentials } from '@aws-sdk/types'
|
|
4
|
+
import { logInfo, logError } from 'log'
|
|
6
5
|
|
|
7
6
|
export class AwsCredentialsClient {
|
|
8
7
|
|
|
@@ -20,7 +19,6 @@ export class AwsCredentialsClient {
|
|
|
20
19
|
return core.getIDToken('sts.amazonaws.com')
|
|
21
20
|
.then(webIdentityToken => {
|
|
22
21
|
logInfo({ message: `[AwsCredentialsClient] Attempting to resolve aws credentials by assuming the role: ${awsRoleToAssume}` })
|
|
23
|
-
logDebug({ message: '[AwsCredentialsClient] webIdentityToken', data: webIdentityToken })
|
|
24
22
|
return stsClient.send(new AssumeRoleWithWebIdentityCommand({
|
|
25
23
|
RoleArn: `arn:aws:iam::${awsAccountId}:role/${awsRoleToAssume}`,
|
|
26
24
|
RoleSessionName: 'GitHubActions',
|
|
@@ -29,6 +27,7 @@ export class AwsCredentialsClient {
|
|
|
29
27
|
}))
|
|
30
28
|
})
|
|
31
29
|
.then(responseData => ({
|
|
30
|
+
// Don't ask
|
|
32
31
|
AccessKeyId: responseData.Credentials.AccessKeyId,
|
|
33
32
|
SessionToken: responseData.Credentials.SessionToken,
|
|
34
33
|
SecretAccessKey: responseData.Credentials.SecretAccessKey,
|
|
@@ -36,11 +35,6 @@ export class AwsCredentialsClient {
|
|
|
36
35
|
sessionToken: responseData.Credentials.SessionToken,
|
|
37
36
|
secretAccessKey: responseData.Credentials.SecretAccessKey,
|
|
38
37
|
}))
|
|
39
|
-
// .then(responseData => responseData.Credentials)
|
|
40
|
-
.then(data => {
|
|
41
|
-
logDebug({ message: '[AwsCredentialsClient] AssumeRoleWithWebIdentityCommand responseData.Credentials', data })
|
|
42
|
-
return data
|
|
43
|
-
})
|
|
44
38
|
.catch(error => {
|
|
45
39
|
logError({ message: '[AwsCredentialsClient] Could not resolve temporary credentials', error })
|
|
46
40
|
return undefined
|
|
@@ -58,17 +58,19 @@ export class DeploymentPlatformClient {
|
|
|
58
58
|
|
|
59
59
|
logInfo({ message: `[DeploymentPlatformClient]: Found deployment platforms [${platforms.map(x => x.platformName).join(', ')}]` })
|
|
60
60
|
|
|
61
|
-
const deploymentPlatform = platforms
|
|
61
|
+
const deploymentPlatform = platforms
|
|
62
|
+
.map(platform => ({ ...platform, activeEnvironment: targetEnvironment }))
|
|
63
|
+
.find(platform => platform.platformName === deploymentTemplate.targetDeploymentPlatform)
|
|
62
64
|
|
|
63
65
|
if (!deploymentPlatform) {
|
|
64
|
-
logError({
|
|
66
|
+
logError({ message: `[DeploymentPlatformClient] Could not find a deployment platform with the name ${deploymentTemplate.targetDeploymentPlatform}` })
|
|
65
67
|
return Promise.reject()
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
69
71
|
|
|
70
72
|
if (deploymentTemplate.type !== SupportedDeploymentTypes.Container) {
|
|
71
|
-
logError({
|
|
73
|
+
logError({ message: `[DeploymentPlatformClient] Unsupported deployment type of ${deploymentTemplate.type}` })
|
|
72
74
|
return Promise.reject()
|
|
73
75
|
}
|
|
74
76
|
|
|
@@ -83,7 +85,7 @@ export class DeploymentPlatformClient {
|
|
|
83
85
|
|
|
84
86
|
})
|
|
85
87
|
})
|
|
86
|
-
.catch(error => logError({
|
|
88
|
+
.catch(error => logError({ message: '[DeploymentPlatformClient] Could not send deployment request', error }))
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]> {
|
|
@@ -6,29 +6,32 @@ import {
|
|
|
6
6
|
} from '@aws-sdk/client-sqs'
|
|
7
7
|
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types'
|
|
8
8
|
import { AwsCredentialsClient } from 'aws-credentials-client'
|
|
9
|
-
import { logInfo, logError } from 'log'
|
|
9
|
+
import { logInfo, logError, logDebug } from 'log'
|
|
10
10
|
|
|
11
11
|
export class DeploymentQueueClient {
|
|
12
12
|
|
|
13
13
|
static sendDeploymentRequest(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest) {
|
|
14
|
-
logInfo({
|
|
14
|
+
logInfo({ message: '[DeploymentQueueClient] Starting deployment sequence' })
|
|
15
15
|
return DeploymentQueueClient.createAwsSqsClient(deploymentPlatform)
|
|
16
16
|
.then(sqsClient => {
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const sendMessageParams = {
|
|
19
19
|
QueueUrl: deploymentPlatform.awsDeploymentSqsArn,
|
|
20
20
|
MessageBody: JSON.stringify(deploymentRequest)
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
logDebug({ message: '[DeploymentQueueClient] SendMessageCommand params', data: sendMessageParams })
|
|
24
|
+
const command = new SendMessageCommand(sendMessageParams)
|
|
22
25
|
|
|
23
26
|
return sqsClient.send(command)
|
|
24
|
-
.then(() => logInfo({
|
|
27
|
+
.then(() => logInfo({ message: '[DeploymentQueueClient] Deployment request sent' }))
|
|
25
28
|
.catch(error => logError({ message: '[DeploymentQueueClient] Could not send deployment request', error }))
|
|
26
29
|
})
|
|
27
30
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
static pollForDeploymentRequests(deploymentPlatform: DeploymentPlatform, handleDeploymentRequest: (deploymentRequest: ContainerDeploymentRequest) => Promise<void>) {
|
|
31
|
-
logInfo({
|
|
34
|
+
logInfo({ message: '[DeploymentQueueClient] Starting polling for deployment requests' })
|
|
32
35
|
DeploymentQueueClient.createAwsSqsClient(deploymentPlatform).then(sqsClient => {
|
|
33
36
|
const FIVE_MINUTES = 3000
|
|
34
37
|
|