Using terraform to create, deploy and host my amplify app

0

Hi, I am trying to create, deploy and host my amplify app using terraform. I am writing the following code to create and host my app.

Create the Amplify app

resource "aws_amplify_app" "SelfServiceDashboard" { name = "SelfServiceDashboard" }

Create the Amplify backend environment

resource "aws_amplify_backend_environment" "SelfServiceDashboard" { app_id = aws_amplify_app.SelfServiceDashboard.id environment_name = "prod" stack_name = "awscloudformation" # Replace with the desired CloudFormation stack name }

Initialize the Amplify project

resource "null_resource" "initialize_amplify_project" { provisioner "local-exec" { command = "amplify init --appId ${aws_amplify_app.SelfServiceDashboard.id}" } }

Pull the existing Amplify project (if it exists)

resource "null_resource" "pull_amplify_project" { depends_on = [null_resource.initialize_amplify_project]

provisioner "local-exec" { command = "amplify pull --appId ${aws_amplify_app.SelfServiceDashboard.id} --envName prod" } }

Trigger the backend environment deployment

resource "null_resource" "trigger_backend_deployment" { depends_on = [aws_amplify_backend_environment.SelfServiceDashboard, null_resource.pull_amplify_project]

provisioner "local-exec" { command = "amplify push --appId ${aws_amplify_app.SelfServiceDashboard.id} --envName prod" } } but the hosting environment is never deployed, it just says this

Waiting to deploy Your deployment is being queued...

could you please help me with the code or guide as to what I am doing wrong here

已提问 9 个月前645 查看次数
1 回答
0

Hello,

The issue can occur due to multiple reasons such as permission issues or the “amplify publish” command not executing completely. Could you kindly confirm with us if you are observing any error, especially for the “amplify publish” or “amplify push” command.

The command “amplify push” will build all your local backend resources and provision it in the cloud. Whereas, “amplify publish” will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud. Hence, in order to start the deployment for the hosting environment we need to execute “amplify publish” command.

Should you be facing any errors, it is suggested to delete the deployment that was stuck and start the deployment again. The steps for deploying Amplify with Terraform can be found here: https://catalog.workshops.aws/amplify-with-terraform/en-US/introduction

AWS
支持工程师
Waqiah
已回答 9 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则