@goldstack/infra-aws 0.3.44 → 0.3.45
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": "@goldstack/infra-aws",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.45",
|
|
4
4
|
"description": "Utilities to work with AWS infrastructure via the cli.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@goldstack/infra": "0.3.
|
|
43
|
-
"@goldstack/utils-config": "0.3.
|
|
44
|
-
"@goldstack/utils-log": "0.2.
|
|
45
|
-
"@goldstack/utils-package": "0.3.
|
|
46
|
-
"@goldstack/utils-sh": "0.4.
|
|
42
|
+
"@goldstack/infra": "0.3.37",
|
|
43
|
+
"@goldstack/utils-config": "0.3.34",
|
|
44
|
+
"@goldstack/utils-log": "0.2.15",
|
|
45
|
+
"@goldstack/utils-package": "0.3.39",
|
|
46
|
+
"@goldstack/utils-sh": "0.4.32",
|
|
47
47
|
"aws-sdk": "2.1055.0",
|
|
48
48
|
"axios": "0.21.2",
|
|
49
49
|
"handlebars": "4.7.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@goldstack/utils-git": "0.1.
|
|
52
|
+
"@goldstack/utils-git": "0.1.35",
|
|
53
53
|
"@types/jest": "^27.5.1",
|
|
54
54
|
"@types/node": "^17.0.33",
|
|
55
55
|
"jest": "^28.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"infraAws.spec.d.ts","sourceRoot":"","sources":["../../src/infraAws.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const infraAws_1 = require("./infraAws");
|
|
7
|
-
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
8
|
-
const assert_1 = __importDefault(require("assert"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const os_1 = __importDefault(require("os"));
|
|
11
|
-
describe('AWS User config', () => {
|
|
12
|
-
it('Should read from AWS credentials in user folder if no config provided', async () => {
|
|
13
|
-
// Skip if not in CI https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
14
|
-
if (!process.env.GITHUB_ACTION) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
console.log('RUN IN CI');
|
|
18
|
-
const awsCredentials = `
|
|
19
|
-
[default]
|
|
20
|
-
aws_access_key_id=fromProfileKey
|
|
21
|
-
aws_secret_access_key=fromProfileSecret
|
|
22
|
-
`;
|
|
23
|
-
(0, utils_sh_1.mkdir)('-p', `${os_1.default.homedir()}/.aws`);
|
|
24
|
-
await (0, utils_sh_1.rmSafe)(`${os_1.default.homedir}/.aws/config`);
|
|
25
|
-
(0, utils_sh_1.write)(awsCredentials, `${os_1.default.homedir}/.aws/credentials`);
|
|
26
|
-
const credentials = await (0, infraAws_1.getAWSUser)('default', './invalid');
|
|
27
|
-
expect(credentials.accessKeyId).toEqual('fromProfileKey');
|
|
28
|
-
expect(credentials.secretAccessKey).toEqual('fromProfileSecret');
|
|
29
|
-
});
|
|
30
|
-
it('Should read AWS credentials process in user folder if no config provided', async () => {
|
|
31
|
-
// Skip if not in CI https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
32
|
-
if (!process.env.GITHUB_ACTION) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const awsConfig = `
|
|
36
|
-
[default]
|
|
37
|
-
region=us-west-2
|
|
38
|
-
credential_process=cat ~/processCredentials.json
|
|
39
|
-
`;
|
|
40
|
-
(0, utils_sh_1.mkdir)('-p', `${os_1.default.homedir()}/.aws`);
|
|
41
|
-
await (0, utils_sh_1.rmSafe)(`${os_1.default.homedir}/.aws/credentials`);
|
|
42
|
-
(0, utils_sh_1.write)(awsConfig, `${os_1.default.homedir}/.aws/config`);
|
|
43
|
-
const processCredentials = `
|
|
44
|
-
{
|
|
45
|
-
"Version": 1,
|
|
46
|
-
"AccessKeyId": "fromProcessCredentialsKey",
|
|
47
|
-
"SecretAccessKey": "fromProcessCredentialsSecret",
|
|
48
|
-
"SessionToken": "the AWS session token for temporary credentials",
|
|
49
|
-
"Expiration": "ISO8601 timestamp when the credentials expire"
|
|
50
|
-
}`;
|
|
51
|
-
(0, utils_sh_1.write)(processCredentials, `${os_1.default.homedir}/processCredentials.json`);
|
|
52
|
-
const credentials = await (0, infraAws_1.getAWSUser)('default', './invalid');
|
|
53
|
-
expect(credentials.accessKeyId).toEqual('fromProcessCredentialsKey');
|
|
54
|
-
expect(credentials.secretAccessKey).toEqual('fromProcessCredentialsSecret');
|
|
55
|
-
});
|
|
56
|
-
it('Should read AWS config from Goldstack config file', async () => {
|
|
57
|
-
const awsConfig = `{
|
|
58
|
-
"users": [
|
|
59
|
-
{
|
|
60
|
-
"name": "goldstack-dev",
|
|
61
|
-
"type": "apiKey",
|
|
62
|
-
"config": {
|
|
63
|
-
"awsAccessKeyId": "dummy",
|
|
64
|
-
"awsSecretAccessKey": "dummy",
|
|
65
|
-
"awsDefaultRegion": "us-west-2"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"name": "goldstack-prod",
|
|
70
|
-
"type": "apiKey",
|
|
71
|
-
"config": {
|
|
72
|
-
"awsAccessKeyId": "dummy-prod",
|
|
73
|
-
"awsSecretAccessKey": "dummy-prod",
|
|
74
|
-
"awsDefaultRegion": "us-west-2"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}`;
|
|
79
|
-
const testDir = './goldstackLocal/tests/getAWSUser';
|
|
80
|
-
(0, utils_sh_1.mkdir)('-p', testDir);
|
|
81
|
-
(0, utils_sh_1.write)(awsConfig, testDir + '/config-embedded.json');
|
|
82
|
-
const credentialsDev = await (0, infraAws_1.getAWSUser)('goldstack-dev', testDir + '/config-embedded.json');
|
|
83
|
-
(0, assert_1.default)(credentialsDev.accessKeyId === 'dummy');
|
|
84
|
-
const credentialsProd = await (0, infraAws_1.getAWSUser)('goldstack-prod', testDir + '/config-embedded.json');
|
|
85
|
-
(0, assert_1.default)(credentialsProd.accessKeyId === 'dummy-prod');
|
|
86
|
-
});
|
|
87
|
-
it('Should read from AWS credentials file', async () => {
|
|
88
|
-
const testDir = './goldstackLocal/tests/getAWSUser';
|
|
89
|
-
const awsConfig = `{
|
|
90
|
-
"users": [
|
|
91
|
-
{
|
|
92
|
-
"name": "dev",
|
|
93
|
-
"type": "profile",
|
|
94
|
-
"config": {
|
|
95
|
-
"profile": "goldstack-dev",
|
|
96
|
-
"awsDefaultRegion": "us-west-2",
|
|
97
|
-
"awsCredentialsFileName": "${path_1.default
|
|
98
|
-
.resolve('./testData/awsCredentials')
|
|
99
|
-
.replace(/\\/g, '/')}"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}`;
|
|
104
|
-
(0, utils_sh_1.mkdir)('-p', testDir);
|
|
105
|
-
(0, utils_sh_1.write)(awsConfig, testDir + '/config.json');
|
|
106
|
-
const credentialsDev = await (0, infraAws_1.getAWSUser)('dev', testDir + '/config.json');
|
|
107
|
-
expect(credentialsDev.secretAccessKey).toEqual('devsecret');
|
|
108
|
-
expect(credentialsDev.accessKeyId).toEqual('devkey');
|
|
109
|
-
});
|
|
110
|
-
it('Should load credentials using a credentials source defined in the credentials file', async () => {
|
|
111
|
-
const testDir = './goldstackLocal/tests/getAWSUser';
|
|
112
|
-
const awsConfig = `{
|
|
113
|
-
"users": [
|
|
114
|
-
{
|
|
115
|
-
"name": "process",
|
|
116
|
-
"type": "profile",
|
|
117
|
-
"config": {
|
|
118
|
-
"profile": "with-process",
|
|
119
|
-
"awsDefaultRegion": "us-west-2",
|
|
120
|
-
"credentialsSource": "process",
|
|
121
|
-
"awsCredentialsFileName": "${path_1.default
|
|
122
|
-
.resolve('./testData/awsCredentials')
|
|
123
|
-
.replace(/\\/g, '/')}"
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}`;
|
|
128
|
-
(0, utils_sh_1.mkdir)('-p', testDir);
|
|
129
|
-
(0, utils_sh_1.write)(awsConfig, testDir + '/config.json');
|
|
130
|
-
const credentialsProcess = await (0, infraAws_1.getAWSUser)('process', testDir + '/config.json');
|
|
131
|
-
expect(credentialsProcess.secretAccessKey).toEqual('processsecret');
|
|
132
|
-
expect(credentialsProcess.accessKeyId).toEqual('processkey');
|
|
133
|
-
});
|
|
134
|
-
it('Should load credentials using a credentials source defined in the config file', async () => {
|
|
135
|
-
const testDir = './goldstackLocal/tests/getAWSUser';
|
|
136
|
-
const awsConfig = `{
|
|
137
|
-
"users": [
|
|
138
|
-
{
|
|
139
|
-
"name": "process-from-config",
|
|
140
|
-
"type": "profile",
|
|
141
|
-
"config": {
|
|
142
|
-
"profile": "with-process",
|
|
143
|
-
"awsDefaultRegion": "us-west-2",
|
|
144
|
-
"credentialsSource": "process",
|
|
145
|
-
"awsConfigFileName": "${path_1.default
|
|
146
|
-
.resolve('./testData/awsConfig')
|
|
147
|
-
.replace(/\\/g, '/')}"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
}`;
|
|
152
|
-
(0, utils_sh_1.mkdir)('-p', testDir);
|
|
153
|
-
(0, utils_sh_1.write)(awsConfig, testDir + '/config.json');
|
|
154
|
-
const credentialsProcessFromConfig = await (0, infraAws_1.getAWSUser)('process-from-config', testDir + '/config.json');
|
|
155
|
-
expect(credentialsProcessFromConfig.secretAccessKey).toEqual('processsecret');
|
|
156
|
-
expect(credentialsProcessFromConfig.accessKeyId).toEqual('processkey');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
//# sourceMappingURL=infraAws.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"infraAws.spec.js","sourceRoot":"","sources":["../../src/infraAws.spec.ts"],"names":[],"mappings":";;;;;AAAA,yCAAwC;AACxC,kDAA2D;AAC3D,oDAA4B;AAC5B,gDAAwB;AACxB,4CAAoB;AAEpB,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;QACrF,gIAAgI;QAChI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;YAC9B,OAAO;SACR;QAED,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,cAAc,GAAG;;;;KAItB,CAAC;QAEF,IAAA,gBAAK,EAAC,IAAI,EAAE,GAAG,YAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpC,MAAM,IAAA,iBAAM,EAAC,GAAG,YAAE,CAAC,OAAO,cAAc,CAAC,CAAC;QAC1C,IAAA,gBAAK,EAAC,cAAc,EAAE,GAAG,YAAE,CAAC,OAAO,mBAAmB,CAAC,CAAC;QAExD,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAU,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC7D,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC1D,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;QACxF,gIAAgI;QAChI,IAAI,CAAC,OAAO,CAAC,GAAG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