I had this issue as well while working on the deployment of an amplify hosted application.
After going through the AWS CLI documentation for Amplify, I found the start-job command. This command allows you to start an amplify job for a specific branch.
You can then create an AwsCustomResource that makes an SDK call to start-job.
This is what I ended up with.
const build_trigger = new customResource.AwsCustomResource(this, 'triggerAppBuild', {
policy: customResource.AwsCustomResourcePolicy.fromSdkCalls({
resources: customResource.AwsCustomResourcePolicy.ANY_RESOURCE
}),
onCreate: {
service: 'Amplify',
action: 'startJob',
physicalResourceId: customResource.PhysicalResourceId.of('app-build-trigger'),
parameters: {
appId: amplifyApp.appId,
branchName: master.branchName,
jobType: 'RELEASE',
jobReason: 'Auto Start build',
}
},
});
Note that you should replace amplifyApp.apiId and master.branchName with your own app ID and branch name. I am using the amplify-alpha, so you may need to get the App ID and branch name another way.