Executing remote-exec via terraform led to my resource to stuck at still creating

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/Terraform

Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • SonarLint - Clean code begins in your IDE with SonarLint
  • SaaSHub - Software Alternatives and Reviews
  • golangapp

    Repository created by AWS CodeStar.

    resource "null_resource" "instance" { depends_on = [ aws_instance.main ] connection { type = "ssh" host = aws_instance.main.public_ip user = "ubuntu" private_key = file("${path.module}/main_key.pem") } provisioner "remote-exec" { inline = [ "sleep 10", "sudo apt update -y", "sudo apt install git -y", "sudo apt install golang -y", "sudo git clone https://github.com/viveksiddhartha/golangapp.git /home/ubuntu/golangapp", "cd golangapp", "sudo go build ./", "./main", "sleep 10" ] } }

  • terraform-aws-ssh-bastion-service

    Terraform plan to deploy ssh bastion as a containerised, stateless service on AWS with IAM based authentication

    You should try to avoid using remote exec with terraform wherever possible. It's not a great fit with the declarative approach that Terraform aims for. Here you would be better off using 'user data' to provision your instance. I have a public project that deploys and builds a Golang app on EC2. It's a bit more complicated than your example here, but it does demonstrate a method for doing what you're trying to do with the approach that I have suggested.

  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts