-
terraform-aws-ssh-bastion-service
Terraform plan to deploy ssh bastion as a containerised, stateless service on AWS with IAM based authentication
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
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" ] } }
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.
Related posts
-
Create and Deploy AWS EKS Cluster with Terraform.
-
No More Passwords! Terraform Module Makes GCP-GitHub Authentication a Breeze
-
Open Source Infrastructure Deployment Tool for Early Stage Startups
-
Stack Grafana deployed on AWS ECS -Part 1 - Create a Cluster
-
Terraform Starter Boilerplate for GCP using Terragrunt