Terraform with AWS basics tutorial
I had the opportunity to assist to the “From Zero to Hero Introduction to Infrastructure as Code with Terraform and AWS” workshop, by the amazing Mayra Espinoza (DevOps engineer at IBM) during the AWS Community Day Lima. It was so good and I want to share what I learned that day.
1.- What we are going to do?
We will implement an API REST with Terraform and AWS. Basically, it will be a “hello world” test from Terraform to AWS. It will take some steps, and what we are gonna instruct Terraform to do, is the following:
i.- Basic Terraform configuration.
ii.- S3 bucket creation.
iii.- Object creation.
iv.- Role creation.
v.- Lambda function creation.
vi-. API REST creation.
vii- Resource creation.
viii.- Method creation.
ix.- Integration.
2.- Requirements
i.- A system running some Linux flavor, MacOS or Windows.
ii.- Some AWS knowledge, a bit of IAM, S3 and Lambda.
iii.- An AWS console account.
3. Lab
1.- In the AWS console, go to IAM:
i.- Create an IAM account with Access type selected as Programmatic access (only).
ii.- Attach existing policies directly.
iii.- Select AdministratorAccess.
iv.- Tags is unnecesary to setup.
v.- Click en Create User.
vi.- Take note of the Access key ID and Secret access key values.
4.- Get the basic files to make the test.
This files has been provided by Mayra Espinoza.
Clone the following git repo for testing purposes.
git clone https://github.com/mayraer11/AWS-TERRAFORM.git
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 12 (delta 0), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), done.
Then we’ll get the following files:
backend.tf: this is the backend we are gonna use.
http_trigger.js: configure the cloud functions.
main.tf: this is the primary entrypoint.
outputs.tf: we define the output variable.
provider.tf: this is our provider, in this case AWS.
terraform.tfvars: configure environment variables.
5.- Download Terraform and unzip it.
https://www.terraform.io/downloads.html
6.- Edit the provider.tf file , and leave just the connection to AWS.
# AWS
provider “aws” {
version = “~> 2.0”
}
7.- Setup the environment variables
This is the right and secure way to make this on production. Don’t hardcode the credentials in the provider.tf file.
export AWS_ACCESS_KEY_ID=”anaccesskey”
export AWS_SECRET_ACCESS_KEY=”asecretkey”
export AWS_DEFAULT_REGION=”us-west-2"
Replace for your own credentials!
8.- Do terraform init .
Note: be sure to run the terraform binary on the same path you have
AWS-TERRAFORM/repo/AWS-TERRAFORM/src/hello-aws , or add the binary to the user path instead.
./terraform init
Initializing the backend…
Successfully configured the backend “local”! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins…
- Checking for available provider plugins…
- Downloading plugin for provider “archive” (hashicorp/archive) 1.2.2…
- Downloading plugin for provider “aws” (hashicorp/aws) 2.28.1…
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = “…” constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.
* provider.archive: version = “~> 1.2”
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands
should now work. If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
9.- Do terraform plan
Oh, this is the better part of using Terraform! The plan is everything what’s going to be done, in details. Oh, it’s sweet…
./terraform plan
Refreshing Terraform state in-memory prior to plan…
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.archive_file.http_trigger: Refreshing state…
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_api_gateway_deployment.MyDemoDeployment will be created
+ resource “aws_api_gateway_deployment” “MyDemoDeployment” {
+ created_date = (known after apply)
+ execution_arn = (known after apply)
+ id = (known after apply)
+ invoke_url = (known after apply)
+ rest_api_id = (known after apply)
+ stage_name = “test”
}
# aws_api_gateway_integration.MyDemoIntegration will be created
+ resource “aws_api_gateway_integration” “MyDemoIntegration” {
+ cache_namespace = (known after apply)
+ connection_type = “INTERNET”
+ http_method = “GET”
+ id = (known after apply)
+ integration_http_method = “POST”
+ passthrough_behavior = (known after apply)
+ resource_id = (known after apply)
+ rest_api_id = (known after apply)
+ timeout_milliseconds = 29000
+ type = “AWS_PROXY”
+ uri = (known after apply)
}
# aws_api_gateway_method.MyDemoMethod will be created
+ resource “aws_api_gateway_method” “MyDemoMethod” {
+ api_key_required = false
+ authorization = “NONE”
+ http_method = “GET”
+ id = (known after apply)
+ resource_id = (known after apply)
+ rest_api_id = (known after apply)
}
# aws_api_gateway_resource.MyDemoResource will be created
+ resource “aws_api_gateway_resource” “MyDemoResource” {
+ id = (known after apply)
+ parent_id = (known after apply)
+ path = (known after apply)
+ path_part = “welcome”
+ rest_api_id = (known after apply)
}
# aws_api_gateway_rest_api.MyDemoAPI will be created
+ resource “aws_api_gateway_rest_api” “MyDemoAPI” {
+ api_key_source = “HEADER”
+ created_date = (known after apply)
+ description = “Demo para AWS Community Day”
+ execution_arn = (known after apply)
+ id = (known after apply)
+ minimum_compression_size = -1
+ name = “MyDemoAPI”
+ root_resource_id = (known after apply)
+ endpoint_configuration {
+ types = (known after apply)
}
}
# aws_iam_role.lambda_execute will be created
+ resource “aws_iam_role” “lambda_execute” {
+ arn = (known after apply)
+ assume_role_policy = jsonencode(
{
+ Statement = [
+ {
+ Action = “sts:AssumeRole”
+ Effect = “Allow”
+ Principal = {
+ Service = “lambda.amazonaws.com”
}
+ Sid = “”
},
]
+ Version = “2012–10–17”
}
)
+ create_date = (known after apply)
+ force_detach_policies = false
+ id = (known after apply)
+ max_session_duration = 3600
+ name = “serverless_lambda_awscommunityday”
+ path = “/”
+ unique_id = (known after apply)
}
# aws_lambda_function.MyDemo will be created
+ resource “aws_lambda_function” “MyDemo” {
+ arn = (known after apply)
+ function_name = “DemoAwsCommunityDay”
+ handler = “main.handler”
+ id = (known after apply)
+ invoke_arn = (known after apply)
+ last_modified = (known after apply)
+ memory_size = 128
+ publish = false
+ qualified_arn = (known after apply)
+ reserved_concurrent_executions = -1
+ role = (known after apply)
+ runtime = “nodejs10.x”
+ s3_bucket = “demoawscommunityday”
+ s3_key = “v1.0.0/http_trigger.zip”
+ source_code_hash = (known after apply)
+ source_code_size = (known after apply)
+ timeout = 3
+ version = (known after apply)
+ tracing_config {
+ mode = (known after apply)
}
}
# aws_lambda_permission.lambda_permission will be created
+ resource “aws_lambda_permission” “lambda_permission” {
+ action = “lambda:InvokeFunction”
+ function_name = (known after apply)
+ id = (known after apply)
+ principal = “apigateway.amazonaws.com”
+ source_arn = (known after apply)
+ statement_id = “AllowAPIGatewayInvoke”
}
# aws_s3_bucket.aws_bucket will be created
+ resource “aws_s3_bucket” “aws_bucket” {
+ acceleration_status = (known after apply)
+ acl = “private”
+ arn = (known after apply)
+ bucket = “demoawscommunityday”
+ bucket_domain_name = (known after apply)
+ bucket_regional_domain_name = (known after apply)
+ force_destroy = false
+ hosted_zone_id = (known after apply)
+ id = (known after apply)
+ region = (known after apply)
+ request_payer = (known after apply)
+ website_domain = (known after apply)
+ website_endpoint = (known after apply)
+ versioning {
+ enabled = true
+ mfa_delete = false
}
}
# aws_s3_bucket_object.object will be created
+ resource “aws_s3_bucket_object” “object” {
+ acl = “private”
+ bucket = “demoawscommunityday”
+ content_type = (known after apply)
+ etag = (known after apply)
+ id = (known after apply)
+ key = “v1.0.0/http_trigger.zip”
+ server_side_encryption = (known after apply)
+ source = “./http_trigger.zip”
+ storage_class = (known after apply)
+ version_id = (known after apply)
}
Plan: 10 to add, 0 to change, 0 to destroy.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Note: You didn’t specify an “-out” parameter to save this plan, so Terraform
can’t guarantee that exactly these actions will be performed if
“terraform apply” is subsequently run.
10.- Do terraform apply
./terraform apply
data.archive_file.http_trigger: Refreshing state…
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_api_gateway_deployment.MyDemoDeployment will be created
+ resource “aws_api_gateway_deployment” “MyDemoDeployment” {
+ created_date = (known after apply)
+ execution_arn = (known after apply)
+ id = (known after apply)
+ invoke_url = (known after apply)
+ rest_api_id = (known after apply)
+ stage_name = “test”
}
# aws_api_gateway_integration.MyDemoIntegration will be created
+ resource “aws_api_gateway_integration” “MyDemoIntegration” {
+ cache_namespace = (known after apply)
+ connection_type = “INTERNET”
+ http_method = “GET”
+ id = (known after apply)
+ integration_http_method = “POST”
+ passthrough_behavior = (known after apply)
+ resource_id = (known after apply)
+ rest_api_id = (known after apply)
+ timeout_milliseconds = 29000
+ type = “AWS_PROXY”
+ uri = (known after apply)
}
# aws_api_gateway_method.MyDemoMethod will be created
+ resource “aws_api_gateway_method” “MyDemoMethod” {
+ api_key_required = false
+ authorization = “NONE”
+ http_method = “GET”
+ id = (known after apply)
+ resource_id = (known after apply)
+ rest_api_id = (known after apply)
}
# aws_api_gateway_resource.MyDemoResource will be created
+ resource “aws_api_gateway_resource” “MyDemoResource” {
+ id = (known after apply)
+ parent_id = (known after apply)
+ path = (known after apply)
+ path_part = “welcome”
+ rest_api_id = (known after apply)
}
# aws_api_gateway_rest_api.MyDemoAPI will be created
+ resource “aws_api_gateway_rest_api” “MyDemoAPI” {
+ api_key_source = “HEADER”
+ created_date = (known after apply)
+ description = “Demo para AWS Community Day”
+ execution_arn = (known after apply)
+ id = (known after apply)
+ minimum_compression_size = -1
+ name = “MyDemoAPI”
+ root_resource_id = (known after apply)
+ endpoint_configuration {
+ types = (known after apply)
}
}
# aws_iam_role.lambda_execute will be created
+ resource “aws_iam_role” “lambda_execute” {
+ arn = (known after apply)
+ assume_role_policy = jsonencode(
{
+ Statement = [
+ {
+ Action = “sts:AssumeRole”
+ Effect = “Allow”
+ Principal = {
+ Service = “lambda.amazonaws.com”
}
+ Sid = “”
},
]
+ Version = “2012–10–17”
}
)
+ create_date = (known after apply)
+ force_detach_policies = false
+ id = (known after apply)
+ max_session_duration = 3600
+ name = “serverless_lambda_awscommunityday”
+ path = “/”
+ unique_id = (known after apply)
}
# aws_lambda_function.MyDemo will be created
+ resource “aws_lambda_function” “MyDemo” {
+ arn = (known after apply)
+ function_name = “DemoAwsCommunityDay”
+ handler = “main.handler”
+ id = (known after apply)
+ invoke_arn = (known after apply)
+ last_modified = (known after apply)
+ memory_size = 128
+ publish = false
+ qualified_arn = (known after apply)
+ reserved_concurrent_executions = -1
+ role = (known after apply)
+ runtime = “nodejs10.x”
+ s3_bucket = “demoawscommunityday”
+ s3_key = “v1.0.0/http_trigger.zip”
+ source_code_hash = (known after apply)
+ source_code_size = (known after apply)
+ timeout = 3
+ version = (known after apply)
+ tracing_config {
+ mode = (known after apply)
}
}
# aws_lambda_permission.lambda_permission will be created
+ resource “aws_lambda_permission” “lambda_permission” {
+ action = “lambda:InvokeFunction”
+ function_name = (known after apply)
+ id = (known after apply)
+ principal = “apigateway.amazonaws.com”
+ source_arn = (known after apply)
+ statement_id = “AllowAPIGatewayInvoke”
}
# aws_s3_bucket.aws_bucket will be created
+ resource “aws_s3_bucket” “aws_bucket” {
+ acceleration_status = (known after apply)
+ acl = “private”
+ arn = (known after apply)
+ bucket = “demoawscommunityday”
+ bucket_domain_name = (known after apply)
+ bucket_regional_domain_name = (known after apply)
+ force_destroy = false
+ hosted_zone_id = (known after apply)
+ id = (known after apply)
+ region = (known after apply)
+ request_payer = (known after apply)
+ website_domain = (known after apply)
+ website_endpoint = (known after apply)
+ versioning {
+ enabled = true
+ mfa_delete = false
}
}
# aws_s3_bucket_object.object will be created
+ resource “aws_s3_bucket_object” “object” {
+ acl = “private”
+ bucket = “demoawscommunityday”
+ content_type = (known after apply)
+ etag = (known after apply)
+ id = (known after apply)
+ key = “v1.0.0/http_trigger.zip”
+ server_side_encryption = (known after apply)
+ source = “./http_trigger.zip”
+ storage_class = (known after apply)
+ version_id = (known after apply)
}
Plan: 10 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only ‘yes’ will be accepted to approve.
Enter a value: yes
aws_iam_role.lambda_execute: Creating…
aws_api_gateway_rest_api.MyDemoAPI: Creating…
aws_s3_bucket.aws_bucket: Creating…
aws_api_gateway_rest_api.MyDemoAPI: Creation complete after 3s [id=7npvcejvlh]
aws_api_gateway_resource.MyDemoResource: Creating…
aws_api_gateway_resource.MyDemoResource: Creation complete after 2s [id=gchl0d]
aws_api_gateway_method.MyDemoMethod: Creating…
aws_iam_role.lambda_execute: Creation complete after 5s [id=serverless_lambda_awscommunityday]
aws_api_gateway_method.MyDemoMethod: Creation complete after 1s [id=agm-7npvcejvlh-gchl0d-GET]
aws_s3_bucket.aws_bucket: Still creating… [10s elapsed]
aws_s3_bucket.aws_bucket: Still creating… [20s elapsed]
aws_s3_bucket.aws_bucket: Creation complete after 28s [id=demoawscommunityday]
aws_s3_bucket_object.object: Creating…
aws_lambda_function.MyDemo: Creating…
aws_lambda_function.MyDemo: Creation complete after 3s [id=DemoAwsCommunityDay]
aws_api_gateway_integration.MyDemoIntegration: Creating…
aws_s3_bucket_object.object: Creation complete after 3s [id=v1.0.0/http_trigger.zip]
aws_api_gateway_integration.MyDemoIntegration: Creation complete after 3s [id=agi-7npvcejvlh-gchl0d-GET]
aws_api_gateway_deployment.MyDemoDeployment: Creating…
aws_api_gateway_deployment.MyDemoDeployment: Still creating… [10s elapsed]
aws_api_gateway_deployment.MyDemoDeployment: Creation complete after 10s [id=ar3iz5]
aws_lambda_permission.lambda_permission: Creating…
aws_lambda_permission.lambda_permission: Creation complete after 3s [id=AllowAPIGatewayInvoke]
Apply complete! Resources: 10 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraformAWS.tfstate
Outputs:
base_url = https://7npvcejvlh.execute-api.us-west-2.amazonaws.com/test/welcome
11.- Confirm that everything is OK
i.- Check if the S3 bucket was created in the AWS console.
ii.- Check the welcome message in the base url you got.
12.- In case you want to clean everything
./terraform destroy
data.archive_file.http_trigger: Refreshing state…
aws_iam_role.lambda_execute: Refreshing state… [id=serverless_lambda_awscommunityday]
aws_api_gateway_rest_api.MyDemoAPI: Refreshing state… [id=kdjsy510i4]
aws_s3_bucket.aws_bucket: Refreshing state… [id=demoawscommunityday]
aws_api_gateway_resource.MyDemoResource: Refreshing state… [id=cxropr]
aws_api_gateway_method.MyDemoMethod: Refreshing state… [id=agm-kdjsy510i4-cxropr-GET]
aws_s3_bucket_object.object: Refreshing state… [id=v1.0.0/http_trigger.zip]
aws_lambda_function.MyDemo: Refreshing state… [id=DemoAwsCommunityDay]
aws_api_gateway_integration.MyDemoIntegration: Refreshing state… [id=agi-kdjsy510i4-cxropr-GET]
aws_api_gateway_deployment.MyDemoDeployment: Refreshing state… [id=dpib65]
aws_lambda_permission.lambda_permission: Refreshing state… [id=AllowAPIGatewayInvoke]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# aws_api_gateway_deployment.MyDemoDeployment will be destroyed
- resource “aws_api_gateway_deployment” “MyDemoDeployment” {
- created_date = “2019–09–14T20:58:36Z” -> null
- execution_arn = “arn:aws:execute-api:us-east-1:748988920544:kdjsy510i4/test” -> null
- id = “dpib65” -> null
- invoke_url = “https://kdjsy510i4.execute-api.us-east-1.amazonaws.com/test" -> null
- rest_api_id = “kdjsy510i4” -> null
- stage_name = “test” -> null
}
# aws_api_gateway_integration.MyDemoIntegration will be destroyed
- resource “aws_api_gateway_integration” “MyDemoIntegration” {
- cache_key_parameters = [] -> null
- cache_namespace = “cxropr” -> null
- connection_type = “INTERNET” -> null
- http_method = “GET” -> null
- id = “agi-kdjsy510i4-cxropr-GET” -> null
- integration_http_method = “POST” -> null
- passthrough_behavior = “WHEN_NO_MATCH” -> null
- request_parameters = {} -> null
- request_templates = {} -> null
- resource_id = “cxropr” -> null
- rest_api_id = “kdjsy510i4” -> null
- timeout_milliseconds = 29000 -> null
- type = “AWS_PROXY” -> null
- uri = “arn:aws:apigateway:us-east-1:lambda:path/2015–03–31/functions/arn:aws:lambda:us-east-1:748988920544:function:DemoAwsComm
unityDay/invocations” -> null
}
# aws_api_gateway_method.MyDemoMethod will be destroyed
- resource “aws_api_gateway_method” “MyDemoMethod” {
- api_key_required = false -> null
- authorization = “NONE” -> null
- authorization_scopes = [] -> null
- http_method = “GET” -> null
- id = “agm-kdjsy510i4-cxropr-GET” -> null
- request_models = {} -> null
- request_parameters = {} -> null
- resource_id = “cxropr” -> null
- rest_api_id = “kdjsy510i4” -> null
}
# aws_api_gateway_resource.MyDemoResource will be destroyed
- resource “aws_api_gateway_resource” “MyDemoResource” {
- id = “cxropr” -> null
- parent_id = “mg64fpdmzc” -> null
- path = “/welcome” -> null
- path_part = “welcome” -> null
- rest_api_id = “kdjsy510i4” -> null
}
# aws_api_gateway_rest_api.MyDemoAPI will be destroyed
- resource “aws_api_gateway_rest_api” “MyDemoAPI” {
- api_key_source = “HEADER” -> null
- binary_media_types = [] -> null
- created_date = “2019–09–14T20:58:23Z” -> null
- description = “Demo para AWS Community Day” -> null
- execution_arn = “arn:aws:execute-api:us-east-1:748988920544:kdjsy510i4” -> null
- id = “kdjsy510i4” -> null
- minimum_compression_size = -1 -> null
- name = “MyDemoAPI” -> null
- root_resource_id = “mg64fpdmzc” -> null
- endpoint_configuration {
- types = [
- “EDGE”,
] -> null
}
}
# aws_iam_role.lambda_execute will be destroyed
- resource “aws_iam_role” “lambda_execute” {
- arn = “arn:aws:iam::748988920544:role/serverless_lambda_awscommunityday” -> null
- assume_role_policy = jsonencode(
{
- Statement = [
- {
- Action = “sts:AssumeRole”
- Effect = “Allow”
- Principal = {
- Service = “lambda.amazonaws.com”
}
- Sid = “”
},
]
- Version = “2012–10–17”
}
) -> null
- create_date = “2019–09–14T20:58:23Z” -> null
- force_detach_policies = false -> null
- id = “serverless_lambda_awscommunityday” -> null
- max_session_duration = 3600 -> null
- name = “serverless_lambda_awscommunityday” -> null
- path = “/” -> null
- tags = {} -> null
- unique_id = “AROA24YZX6LQK4PXQAQWP” -> null
}
# aws_lambda_function.MyDemo will be destroyed
- resource “aws_lambda_function” “MyDemo” {
- arn = “arn:aws:lambda:us-east-1:748988920544:function:DemoAwsCommunityDay” -> null
- function_name = “DemoAwsCommunityDay” -> null
- handler = “main.handler” -> null
- id = “DemoAwsCommunityDay” -> null
- invoke_arn = “arn:aws:apigateway:us-east-1:lambda:path/2015–03–31/functions/arn:aws:lambda:us-east-1:748988920544:function:Demo
AwsCommunityDay/invocations” -> null
- last_modified = “2019–09–14T20:58:37.604+0000” -> null
- layers = [] -> null
- memory_size = 128 -> null
- publish = false -> null
- qualified_arn = “arn:aws:lambda:us-east-1:748988920544:function:DemoAwsCommunityDay:$LATEST” -> null
- reserved_concurrent_executions = -1 -> null
- role = “arn:aws:iam::748988920544:role/serverless_lambda_awscommunityday” -> null
- runtime = “nodejs10.x” -> null
- s3_bucket = “demoawscommunityday” -> null
- s3_key = “v1.0.0/http_trigger.zip” -> null
- source_code_hash = “NhGxmaW3ZgUbBL6TWgP8V6yx9AY+uV6oi3y8GRaOIOw=” -> null
- source_code_size = 324 -> null
- tags = {} -> null
- timeout = 3 -> null
- version = “$LATEST” -> null
- tracing_config {
- mode = “PassThrough” -> null
}
}
# aws_lambda_permission.lambda_permission will be destroyed
- resource “aws_lambda_permission” “lambda_permission” {
- action = “lambda:InvokeFunction” -> null
- function_name = “arn:aws:lambda:us-east-1:748988920544:function:DemoAwsCommunityDay” -> null
- id = “AllowAPIGatewayInvoke” -> null
- principal = “apigateway.amazonaws.com” -> null
- source_arn = “arn:aws:execute-api:us-east-1:748988920544:kdjsy510i4/test/*/welcome” -> null
- statement_id = “AllowAPIGatewayInvoke” -> null
}
# aws_s3_bucket.aws_bucket will be destroyed
- resource “aws_s3_bucket” “aws_bucket” {
- acl = “private” -> null
- arn = “arn:aws:s3:::demoawscommunityday” -> null
- bucket = “demoawscommunityday” -> null
- bucket_domain_name = “demoawscommunityday.s3.amazonaws.com” -> null
- bucket_regional_domain_name = “demoawscommunityday.s3.amazonaws.com” -> null
- force_destroy = false -> null
- hosted_zone_id = “Z3AQBSTGFYJSTF” -> null
- id = “demoawscommunityday” -> null
- region = “us-east-1” -> null
- request_payer = “BucketOwner” -> null
- tags = {} -> null
- versioning {
- enabled = true -> null
- mfa_delete = false -> null
}
}
# aws_s3_bucket_object.object will be destroyed
- resource “aws_s3_bucket_object” “object” {
- acl = “private” -> null
- bucket = “demoawscommunityday” -> null
- content_type = “binary/octet-stream” -> null
- etag = “80d6c1052de608b9c35c03e91db4c074” -> null
- id = “v1.0.0/http_trigger.zip” -> null
- key = “v1.0.0/http_trigger.zip” -> null
- metadata = {} -> null
- source = “./http_trigger.zip” -> null
- storage_class = “STANDARD” -> null
- tags = {} -> null
- version_id = “Iboqj8tgdU.yERIzIyloiFg0W_NDcEcd” -> null
}
Plan: 0 to add, 0 to change, 10 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only ‘yes’ will be accepted to confirm.
Enter a value: yes
aws_lambda_permission.lambda_permission: Destroying… [id=AllowAPIGatewayInvoke]
aws_s3_bucket_object.object: Destroying… [id=v1.0.0/http_trigger.zip]
aws_lambda_permission.lambda_permission: Destruction complete after 1s
aws_api_gateway_deployment.MyDemoDeployment: Destroying… [id=dpib65]
aws_s3_bucket_object.object: Destruction complete after 1s
aws_api_gateway_deployment.MyDemoDeployment: Destruction complete after 2s
aws_api_gateway_integration.MyDemoIntegration: Destroying… [id=agi-kdjsy510i4-cxropr-GET]
aws_api_gateway_integration.MyDemoIntegration: Destruction complete after 0s
aws_api_gateway_method.MyDemoMethod: Destroying… [id=agm-kdjsy510i4-cxropr-GET]
aws_lambda_function.MyDemo: Destroying… [id=DemoAwsCommunityDay]
aws_lambda_function.MyDemo: Destruction complete after 1s
aws_api_gateway_method.MyDemoMethod: Destruction complete after 1s
aws_api_gateway_resource.MyDemoResource: Destroying… [id=cxropr]
aws_iam_role.lambda_execute: Destroying… [id=serverless_lambda_awscommunityday]
aws_s3_bucket.aws_bucket: Destroying… [id=demoawscommunityday]
aws_api_gateway_resource.MyDemoResource: Destruction complete after 0s
aws_api_gateway_rest_api.MyDemoAPI: Destroying… [id=kdjsy510i4]
aws_s3_bucket.aws_bucket: Destruction complete after 0s
aws_api_gateway_rest_api.MyDemoAPI: Destruction complete after 1s
aws_iam_role.lambda_execute: Destruction complete after 1s
Destroy complete! Resources: 10 destroyed.