Pausing the theory, let us quickly jump into an example. Our goal is to set up the API Gateway for the previously deployed books API as a target. Follow these steps:
- Let us create a new project and write a new Terraform script that creates and deploys an API on Amazon API Gateway, as follows:
touch $GOPATH/src/github.com/git-user/chapter13/intro/api_gateway.tf
It also links our EC2 instance and API endpoints.
- Let us add the Gateway REST API component to the script:
// New API on Amazon API Gatewayresource "aws_api_gateway_rest_api" "test" { name = "EC2Example" description = "Terraform EC2 REST API Example" endpoint_configuration { types = ["REGIONAL"] }}
It takes a few important attributes, ...