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 Risposta
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
TECNICO DI SUPPORTO
Waqiah
con risposta 9 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande