diff --git a/packages/@aws-cdk/aws-amplify-alpha/lib/branch.ts b/packages/@aws-cdk/aws-amplify-alpha/lib/branch.ts index 7638a15abcf15..daf30492f63e4 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/lib/branch.ts +++ b/packages/@aws-cdk/aws-amplify-alpha/lib/branch.ts @@ -254,7 +254,7 @@ class AmplifyAssetDeploymentProvider extends NestedStack { this, 'amplify-asset-deployment-is-complete', { - entry: path.join(__dirname, '..', '..', 'custom-resource-handlers', 'dist', 'aws-amplify-alpha', 'asset-deployment-handler', 'index.js'), + entry: path.join(__dirname, '..', 'custom-resource-handlers', 'dist', 'aws-amplify-alpha', 'asset-deployment-handler', 'index.js'), handler: 'isComplete', initialPolicy: [ new iam.PolicyStatement({ diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/asset.9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364/index.js b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/asset.9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364/index.js deleted file mode 100644 index bbc9855f0e48e..0000000000000 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/asset.9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364/index.js +++ /dev/null @@ -1,110 +0,0 @@ -"use strict"; - -// packages/@aws-cdk/custom-resource-handlers/dist/aws-amplify-alpha/asset-deployment-handler/index.js -var n = Object.defineProperty; -var h = Object.getOwnPropertyDescriptor; -var f = Object.getOwnPropertyNames; -var b = Object.prototype.hasOwnProperty; -var C = (t, e) => { - for (var s in e) - n(t, s, { get: e[s], enumerable: true }); -}; -var I = (t, e, s, o) => { - if (e && typeof e == "object" || typeof e == "function") - for (let r of f(e)) - !b.call(t, r) && r !== s && n(t, r, { get: () => e[r], enumerable: !(o = h(e, r)) || o.enumerable }); - return t; -}; -var A = (t) => I(n({}, "__esModule", { value: true }), t); -var P = {}; -C(P, { isComplete: () => w, onEvent: () => v }); -module.exports = A(P); -var c = require("@aws-sdk/client-amplify"); -var l = require("@aws-sdk/client-s3"); -var a = require("@aws-sdk/client-s3"); -var m = require("@aws-sdk/s3-request-presigner"); -var p = class { - constructor(e) { - this.requestType = e.RequestType, this.requestId = e.RequestId, this.logicalResourceId = e.LogicalResourceId, this.physicalResourceId = e.PhysicalResourceId, this.event = e; - } - onEvent() { - switch (this.requestType) { - case "Create": - return this.onCreate(); - case "Update": - return this.onUpdate(); - case "Delete": - return this.onDelete(); - } - throw new Error(`Invalid request type ${this.requestType}`); - } - isComplete() { - switch (this.requestType) { - case "Create": - return this.isCreateComplete(); - case "Update": - return this.isUpdateComplete(); - case "Delete": - return this.isDeleteComplete(); - } - throw new Error(`Invalid request type ${this.requestType}`); - } - log(e) { - console.log(JSON.stringify(e, void 0, 2)); - } -}; -var i = class extends p { - constructor(e, s, o) { - super(o), this.props = this.event.ResourceProperties, this.amplify = e, this.s3 = s; - } - async onCreate() { - console.log("deploying to Amplify with options:", JSON.stringify(this.props, void 0, 2)); - let e = await this.amplify.listJobs({ appId: this.props.AppId, branchName: this.props.BranchName, maxResults: 1 }); - if (e.jobSummaries && e.jobSummaries.find((y) => y.status === "PENDING")) - return Promise.reject("Amplify job already running. Aborting deployment."); - let s = new a.GetObjectCommand({ Bucket: this.props.S3BucketName, Key: this.props.S3ObjectKey }), o = await (0, m.getSignedUrl)(this.s3, s); - return { AmplifyJobId: (await this.amplify.startDeployment({ appId: this.props.AppId, branchName: this.props.BranchName, sourceUrl: o })).jobSummary?.jobId }; - } - async isCreateComplete() { - return this.isActive(this.event.AmplifyJobId); - } - async onDelete() { - } - async isDeleteComplete() { - return { IsComplete: true }; - } - async onUpdate() { - return this.onCreate(); - } - async isUpdateComplete() { - return this.isActive(this.event.AmplifyJobId); - } - async isActive(e) { - if (!e) - throw new Error("Unable to determine Amplify job status without job id"); - let s = await this.amplify.getJob({ appId: this.props.AppId, branchName: this.props.BranchName, jobId: e }); - if (s.job?.summary?.status === "SUCCEED") - return { IsComplete: true, Data: { JobId: e, Status: s.job.summary.status } }; - if (s.job?.summary?.status === "FAILED" || s.job?.summary?.status === "CANCELLED") - throw new Error(`Amplify job failed with status: ${s.job?.summary?.status}`); - return { IsComplete: false }; - } -}; -var R = "Custom::AmplifyAssetDeployment"; -var d = { logger: console }; -var E = new c.Amplify(d); -var g = new l.S3(d); -async function v(t) { - return u(t).onEvent(); -} -async function w(t) { - return u(t).isComplete(); -} -function u(t) { - switch (t.ResourceType) { - case R: - return new i(E, g, t); - default: - throw new Error(`Unsupported resource type "${t.ResourceType}"`); - } -} diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json index b9004b1e7df51..9c9665a9ed57e 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json +++ b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.assets.json @@ -27,19 +27,6 @@ } } }, - "9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364": { - "source": { - "path": "asset.9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364", - "packaging": "zip" - }, - "destinations": { - "current_account-current_region": { - "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364.zip", - "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" - } - } - }, "c014eecccbb25b3f9b2930f62990f5a373bb117a6c78807df15d78a5ac33e9cd": { "source": { "path": "asset.c014eecccbb25b3f9b2930f62990f5a373bb117a6c78807df15d78a5ac33e9cd", @@ -53,7 +40,7 @@ } } }, - "2f9d2632b48a4f92f6691c3e3cfcbeb47798c945a2d03b93514de1a3d3ec72ed": { + "d43fb7d2905864414e4778c7de7f1a874634c94930fb3c2e0ce4aef8d44fcbbd": { "source": { "path": "cdkamplifyappassetdeploymentcomamazonawscdkcustomresourcesamplifyassetdeploymentprovider02396C99.nested.template.json", "packaging": "file" @@ -61,12 +48,12 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "2f9d2632b48a4f92f6691c3e3cfcbeb47798c945a2d03b93514de1a3d3ec72ed.json", + "objectKey": "d43fb7d2905864414e4778c7de7f1a874634c94930fb3c2e0ce4aef8d44fcbbd.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "c221e6276b2eea7f782d562cdf2ea6004fd2456f2dbf4de21ff01554544f6d3e": { + "e30313963257eb2802270982da6029e53020e8e4c8e9d24250a5e375cce86689": { "source": { "path": "cdk-amplify-app-asset-deployment.template.json", "packaging": "file" @@ -74,7 +61,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "c221e6276b2eea7f782d562cdf2ea6004fd2456f2dbf4de21ff01554544f6d3e.json", + "objectKey": "e30313963257eb2802270982da6029e53020e8e4c8e9d24250a5e375cce86689.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.template.json b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.template.json index 9227907cdc9e5..87b4a49cec79d 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.template.json +++ b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdk-amplify-app-asset-deployment.template.json @@ -90,7 +90,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/2f9d2632b48a4f92f6691c3e3cfcbeb47798c945a2d03b93514de1a3d3ec72ed.json" + "/d43fb7d2905864414e4778c7de7f1a874634c94930fb3c2e0ce4aef8d44fcbbd.json" ] ] } diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdkamplifyappassetdeploymentcomamazonawscdkcustomresourcesamplifyassetdeploymentprovider02396C99.nested.template.json b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdkamplifyappassetdeploymentcomamazonawscdkcustomresourcesamplifyassetdeploymentprovider02396C99.nested.template.json index e361b257eb42e..363d1a0c2fda3 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdkamplifyappassetdeploymentcomamazonawscdkcustomresourcesamplifyassetdeploymentprovider02396C99.nested.template.json +++ b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/cdkamplifyappassetdeploymentcomamazonawscdkcustomresourcesamplifyassetdeploymentprovider02396C99.nested.template.json @@ -144,7 +144,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364.zip" + "S3Key": "85f7bb0ac0b4da3571afd49c891d631f4f07c0ef710a02046d3a9abd8d9d4604.zip" }, "Environment": { "Variables": { diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/manifest.json index 2b578594c37fd..91f09158aa629 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c221e6276b2eea7f782d562cdf2ea6004fd2456f2dbf4de21ff01554544f6d3e.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e30313963257eb2802270982da6029e53020e8e4c8e9d24250a5e375cce86689.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/tree.json b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/tree.json index c59cf57a9e7ff..2ced9b70a065c 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-amplify-alpha/test/integ.app-asset-deployment.js.snapshot/tree.json @@ -470,7 +470,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "9307ab790c544d7c4d94504a1c950222bbfc119c2c12b44440ad46939e0b6364.zip" + "s3Key": "85f7bb0ac0b4da3571afd49c891d631f4f07c0ef710a02046d3a9abd8d9d4604.zip" }, "environment": { "variables": { @@ -1353,7 +1353,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/2f9d2632b48a4f92f6691c3e3cfcbeb47798c945a2d03b93514de1a3d3ec72ed.json" + "/d43fb7d2905864414e4778c7de7f1a874634c94930fb3c2e0ce4aef8d44fcbbd.json" ] ] }