@aws-amplify/cli-internal
Version:
Amplify CLI
36 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.findS3NestedStack = exports.StorageS3ForwardRefactorer = exports.S3_BUCKET_TYPE = void 0;
const forward_category_refactorer_1 = require("../workflow/forward-category-refactorer");
exports.S3_BUCKET_TYPE = 'AWS::S3::Bucket';
class StorageS3ForwardRefactorer extends forward_category_refactorer_1.ForwardCategoryRefactorer {
async fetchSourceStackId() {
return this.findNestedStack(this.gen1Env, 'storage' + this.resource.resourceName);
}
async fetchDestStackId() {
return findS3NestedStack(this.gen2Branch);
}
resourceTypes() {
return [exports.S3_BUCKET_TYPE];
}
}
exports.StorageS3ForwardRefactorer = StorageS3ForwardRefactorer;
async function findS3NestedStack(facade) {
var _a;
const stacks = await facade.fetchNestedStacks();
for (const s of stacks) {
const id = (_a = s.LogicalResourceId) !== null && _a !== void 0 ? _a : '';
if (!id.startsWith('storage'))
continue;
const stackId = s.PhysicalResourceId;
if (!stackId)
continue;
const template = await facade.fetchTemplate(stackId);
const hasS3 = Object.values(template.Resources).some((r) => r.Type === exports.S3_BUCKET_TYPE);
if (hasS3)
return stackId;
}
return undefined;
}
exports.findS3NestedStack = findS3NestedStack;
//# sourceMappingURL=storage-forward.js.map