Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Create Terraform provisioner #21

Open
Fodoj opened this issue Apr 29, 2020 · 0 comments
Open

Idea: Create Terraform provisioner #21

Fodoj opened this issue Apr 29, 2020 · 0 comments

Comments

@Fodoj
Copy link

Fodoj commented Apr 29, 2020

First of all, thanks for a great helper tools - really useful and simple.

Recently I integrated ssm-run into Terraform, basically replacing SSH-based bootstrapping with Session Manager. This allows also to bootstrap completely private instances, without public IP or any jump host.

I am passing instance ID and bootstrap script to the ssm-init script:

  provisioner "local-exec" {
    command = "${path.module}/bootstrap/ssm-init.sh ${self.id} ${var.bootstrap_script_path}"
  }

And the ssm-init.sh script (not - totally not perfect, just a first version, but it works):

#!/bin/bash

instance=$1
script=$2

while true :
do
  result=$(ssm-run -i $instance -file $script -log-level 1 | grep "1 SUCCESS")

  if [ $? == 0 ]; then
    echo "Instance provisioned!"
    break
  fi

  echo 'SSM Sessions are not available yet. Sleeping for 5 seconds.'
  sleep 5
done

As ssm-helpers are written in Go, it should be possible to integrate it as a provisioner in AWS provider for Terraform. Just an idea I thought I shall share here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant