aws-architect 6.7.142 → 6.7.144
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/index.d.ts +1 -0
- package/lib/BucketManager.js +14 -3
- package/lib/CloudFormationDeployer.js +1 -1
- package/package.json +2 -1
package/index.d.ts
CHANGED
package/lib/BucketManager.js
CHANGED
|
@@ -4,6 +4,7 @@ let path = require('path');
|
|
|
4
4
|
const { createHash } = require('crypto');
|
|
5
5
|
const { lookup } = require('mime-types');
|
|
6
6
|
const { S3Client, HeadBucketCommand, CreateBucketCommand, PutPublicAccessBlockCommand, PutBucketLifecycleConfigurationCommand } = require('@aws-sdk/client-s3');
|
|
7
|
+
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
|
|
7
8
|
|
|
8
9
|
const contentTypeMappingConst = {
|
|
9
10
|
'.ico': 'image/x-icon',
|
|
@@ -157,6 +158,13 @@ class BucketManager {
|
|
|
157
158
|
async ensureBucketExists(bucket) {
|
|
158
159
|
const region = this.S3Manager.config.region;
|
|
159
160
|
const s3Client = new S3Client({ region });
|
|
161
|
+
const stsClient = new STSClient({ region });
|
|
162
|
+
|
|
163
|
+
const { Account: accountId } = await stsClient.send(new GetCallerIdentityCommand({}));
|
|
164
|
+
|
|
165
|
+
if (!bucket.includes(accountId) || !bucket.includes(region)) {
|
|
166
|
+
throw { title: 'Bucket name must include both the AWS account ID and the region', bucket, accountId, region };
|
|
167
|
+
}
|
|
160
168
|
|
|
161
169
|
const bucketLifecycleConfigurationParams = {
|
|
162
170
|
Bucket: bucket,
|
|
@@ -174,6 +182,7 @@ class BucketManager {
|
|
|
174
182
|
|
|
175
183
|
try {
|
|
176
184
|
await s3Client.send(new HeadBucketCommand({ Bucket: bucket }));
|
|
185
|
+
return;
|
|
177
186
|
} catch (error) {
|
|
178
187
|
if (error.name !== 'NotFound') {
|
|
179
188
|
throw { title: 'Failed to validate deployment bucket is available', error, bucket };
|
|
@@ -185,16 +194,18 @@ class BucketManager {
|
|
|
185
194
|
params.CreateBucketConfiguration = { LocationConstraint: region };
|
|
186
195
|
}
|
|
187
196
|
try {
|
|
188
|
-
console.log(`[AWS Architect] (S3) -
|
|
197
|
+
console.log(`[AWS Architect] (S3) - Creating deployment bucket because it does not exist: ${bucket}`);
|
|
189
198
|
await s3Client.send(new CreateBucketCommand(params));
|
|
190
199
|
} catch (error) {
|
|
191
|
-
if (error.name === 'BucketAlreadyExists') {
|
|
200
|
+
if (error.name === 'BucketAlreadyExists' || error.name === 'BucketAlreadyOwnedByYou') {
|
|
192
201
|
return;
|
|
193
202
|
}
|
|
194
203
|
throw error;
|
|
195
204
|
}
|
|
196
205
|
await s3Client.send(new PutPublicAccessBlockCommand({
|
|
197
|
-
Bucket: bucket,
|
|
206
|
+
Bucket: bucket,
|
|
207
|
+
PublicAccessBlockConfiguration: { BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true },
|
|
208
|
+
ExpectedBucketOwner: accountId
|
|
198
209
|
}));
|
|
199
210
|
await s3Client.send(new PutBucketLifecycleConfigurationCommand(bucketLifecycleConfigurationParams));
|
|
200
211
|
}
|
|
@@ -553,7 +553,7 @@ class CloudFormationDeployer {
|
|
|
553
553
|
const deployToAdditionalRegionsParams = {
|
|
554
554
|
StackSetName: options.stackSetName,
|
|
555
555
|
DeploymentTargets: {
|
|
556
|
-
OrganizationalUnitIds: rootOrgsInfo.Roots.map(org => org.Id)
|
|
556
|
+
OrganizationalUnitIds: options.orgIds || rootOrgsInfo.Roots.map(org => org.Id)
|
|
557
557
|
},
|
|
558
558
|
Regions: newRegions,
|
|
559
559
|
OperationId: changeSetName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-architect",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.144",
|
|
4
4
|
"description": "AWS Architect is a node based tool to configure and deploy AWS-based microservices.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@aws-sdk/client-cloudformation": "^3.1000.0",
|
|
22
22
|
"@aws-sdk/client-s3": "^3.1000",
|
|
23
|
+
"@aws-sdk/client-sts": "^3.1000",
|
|
23
24
|
"archiver": "^5.3.0",
|
|
24
25
|
"body-parser": "^1.18.2",
|
|
25
26
|
"commander": "^2.5.0",
|