Event-driven architecture

What we need first is some code to install Terraform, get our plan, and apply it. Open up a new file, paste in the following code, and save it as terraform.py:

# -*- coding: utf-8 -*-# adapted from https://github.com/FitnessKeeper/terraform-lambdaimport osimport subprocessimport urllibimport boto3# Version of Terraform that we're usingTERRAFORM_VERSION = '0.11.11'# Download URL for TerraformTERRAFORM_DOWNLOAD_URL = (    'https://releases.hashicorp.com/terraform/%s/terraform_%s_linux_amd64.zip'    % (TERRAFORM_VERSION, TERRAFORM_VERSION))# Paths where Terraform should be installedTERRAFORM_DIR = os.path.join('/tmp', 'terraform_%s' % TERRAFORM_VERSION)TERRAFORM_PATH = os.path.join(TERRAFORM_DIR, 'terraform')def check_call(args): ...

Get Implementing Cloud Design Patterns for AWS - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.