2
votes

I'm working on deploying some servers in the AWS cloud with another engineer. We have written the IaC in Terraform and Terragrunt to provision an Auto-scaling Group. We were wondering what would be the proper approach for configuring the ec2 instances that are created by the ASG:

  • Ansible or,
  • Use the User Data in the launch configuration to run a bash script

In the user data script, we are writing some configuration files, importing some secrets and running a few containers.

2

2 Answers

2
votes

The right answer totally depends on you!

If you already have ansible playbooks that you can run locally, I'd use them!

If you already have bash scripts that can bootstrap your instances, I'd use them!

Either way, you'll need to utilize user-data to either:

  • Install Ansible, load your playbooks and run
  • Simply run your bash code

What matters here is what works best for your team to understand and to maintain over time

I'd personally recommend using only bash within user-data because it reduces complexity (less need to learn Ansible for an engineer unfamiliar with it)

Hope this helps!

0
votes

I will always prefer for bash or power-shell script to invoked through user data rather than Ansible as I am more comfortable to write bash/powershell scripts. So basically, its choice and how convenient you are in Ansible. If you need any sample user data code to invoke bash, pls let me know.