Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (5.6k points)
I want to migrate my config management on AWS to Terraform to make it more pluggable. What I want is the Possibility to manage rolling updates to Autoscaling Group where Terraform waits until the new instances are in sevices before it destroys the old infrastructure. This works fine with "bare" infrastructure. But I ran into a problem when updating the actual app instances. The code is deployed via AWS CodeDeploy and I can tell Terraform to use the generated name of the new Autoscaling Group as a deployment target but it doesn't deploy the code to the new instances on startup. When I manually select "deploy changes to the deployment group" the deployment starts successfully. Any ideas on how to automate this step?

1 Answer

0 votes
by (12.4k points)

You need to install something like AWS-CLI where you're running terraform.

You need to get the dependencies set up so that your CodeDeploy step would be one of the last things to be executed. If that is not the case you can play with "depends_on".

You can refer to the documentation here.

And once your code is posted, you would just need to add a 

resource "something" "some_name" {

    # Whatever config you've setup for the resource

    provisioner "local-exec" {

        command = "aws deploy create-deployment"

  }

}

The AWS deploy created-deployment command is not yet complete, so you'll have to play with that in your environment till you have got the values needed to trigger the rollout but hopefully this is enough to get you started.

Do you want to master AWS? Then do check out the AWS Developer Associate Certification by Intellipaat.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...