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

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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠