Thanatos-Delta
Thanatos-Delta

Reputation: 97

How can you use AWS Lambda scripts to deploy AWS Infrastructure with Terraform

I have already my whole AWS infrastructure set up in Terraform and everything works fine. So now, instead of deploying it from my local machine running terraform apply, I want to deploy my Infrastructure with an AWS Lambda Script completely serverless. Is there anyone who knows how to do this or where to read about this concept? Didn't find anything useful on the internet until now.

I think my sourcecode could lie on a S3 Bucket and the Lambda function grabs it, and runs it in terraform also set up in the function itself i guess due to terraform is such a small program.

Upvotes: 2

Views: 1978

Answers (1)

Marcin
Marcin

Reputation: 238209

I would attempt that as follows:

  1. Create a lambda container image which would include official terraform binary. The actual lambda function code would use, lets say, python's python-terraform package to interact with the binary. Or directly invoke the binary using subprocess.run.
  2. Setup a lambda execution role with all the permissions needed for creation of your resources.
  3. Create a lambda function using the container image.

I haven't tried that personally yet, but I think it is something that should work.

Upvotes: 2

Related Questions