Skip to content

Commit

Permalink
fix: ProvisionedThroughputExceededException dynamodb links table
Browse files Browse the repository at this point in the history
  • Loading branch information
billmetangmo committed Sep 1, 2024
1 parent cf9b9b9 commit 11bff33
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ resource "aws_dynamodb_table" "Users" {

resource "aws_dynamodb_table" "Link_table" {
name = (terraform.workspace == "mtchoun-mouh-master") ? var.table_links : "${terraform.workspace}-${var.table_links}"
billing_mode = "PROVISIONED"
read_capacity = 1
billing_mode = "PAY_PER_REQUEST"
read_capacity = 3
write_capacity = 1
hash_key = "link"

Expand Down Expand Up @@ -300,7 +300,6 @@ resource "aws_s3_bucket_object" "example_file" {
module "cors" {
source = "squidfunk/api-gateway-enable-cors/aws"
version = "0.3.3"

api_id = aws_api_gateway_rest_api.api.id
api_resource_id = aws_api_gateway_resource.resource.id
}
Expand Down

3 comments on commit 11bff33

@billmetangmo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Plan Failed

CI link

Error: expected length of bucket to be in the range (0 - 63), got mtchoun-mouh-fix-provisionned-trhoughpout-mtchoun-mouh.mongulu.cm
 
   with aws_s3_bucket.website,
   on main.tf line 17, in resource "aws_s3_bucket" "website":
   17:   bucket        = (terraform.workspace == "mtchoun-mouh-master") ? var.WEBSITE_BUCKET_NAME : "${terraform.workspace}-${var.WEBSITE_BUCKET_NAME}"
 

Operation failed: failed running terraform plan (exit 1)
  • Create
    • aws_api_gateway_deployment.test
    • aws_api_gateway_integration.integration
    • aws_api_gateway_method.method
    • aws_api_gateway_method_response.method_response_200
    • aws_api_gateway_resource.resource
    • aws_api_gateway_rest_api.api
    • aws_cloudwatch_event_rule.scheduler
    • aws_cloudwatch_event_target.target
    • aws_dynamodb_table.Link_table
    • aws_dynamodb_table.Register
    • aws_dynamodb_table.Users
    • aws_lambda_function.lambda
    • aws_lambda_function.scan
    • aws_lambda_layer_version.test_lambda_layer
    • aws_lambda_permission.allow_cloudwatch_to_call_check_foo
    • aws_lambda_permission.apigw_lambda
    • aws_s3_bucket.images
    • local_file.index_page
    • module.cors.aws_api_gateway_integration._
    • module.cors.aws_api_gateway_integration_response._
    • module.cors.aws_api_gateway_method._
    • module.cors.aws_api_gateway_method_response._
Change Result (Click me)
Changes to Outputs:
  + register_table = "mtchoun-mouh-fix-provisionned-trhoughpout-Register"
  + stage_url      = (known after apply)
╷
│ Error: expected length of bucket to be in the range (0 - 63), got mtchoun-mouh-fix-provisionned-trhoughpout-mtchoun-mouh.mongulu.cm
│ 
│   with aws_s3_bucket.website,
│   on main.tf line 17, in resource "aws_s3_bucket" "website":17:   bucket        = (terraform.workspace == "mtchoun-mouh-master") ? var.WEBSITE_BUCKET_NAME : "${terraform.workspace}-${var.WEBSITE_BUCKET_NAME}"
│ 
╵
Operation failed: failed running terraform plan (exit 1)

@billmetangmo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan Result

CI link

Plan: 26 to add, 0 to change, 0 to destroy.
  • Create
    • aws_api_gateway_deployment.test
    • aws_api_gateway_integration.integration
    • aws_api_gateway_method.method
    • aws_api_gateway_method_response.method_response_200
    • aws_api_gateway_resource.resource
    • aws_api_gateway_rest_api.api
    • aws_cloudwatch_event_rule.scheduler
    • aws_cloudwatch_event_target.target
    • aws_dynamodb_table.Link_table
    • aws_dynamodb_table.Register
    • aws_dynamodb_table.Users
    • aws_lambda_function.lambda
    • aws_lambda_function.scan
    • aws_lambda_layer_version.test_lambda_layer
    • aws_lambda_permission.allow_cloudwatch_to_call_check_foo
    • aws_lambda_permission.apigw_lambda
    • aws_s3_bucket.images
    • aws_s3_bucket.website
    • aws_s3_bucket_object.example_file
    • aws_s3_bucket_policy.website
    • aws_s3_bucket_public_access_block.website
    • local_file.index_page
    • module.cors.aws_api_gateway_integration._
    • module.cors.aws_api_gateway_integration_response._
    • module.cors.aws_api_gateway_method._
    • module.cors.aws_api_gateway_method_response._
Change Result (Click me)
  # aws_api_gateway_deployment.test will be created
  + resource "aws_api_gateway_deployment" "test" {
      + 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    = "mtchoun-mouh-fix-tro-dev"
    }

  # aws_api_gateway_integration.integration will be created
  + resource "aws_api_gateway_integration" "integration" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + 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.method will be created
  + resource "aws_api_gateway_method" "method" {
      + api_key_required = false
      + authorization    = "NONE"
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_method_response.method_response_200 will be created
  + resource "aws_api_gateway_method_response" "method_response_200" {
      + http_method         = "POST"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = true
          + "method.response.header.Access-Control-Allow-Methods" = false
          + "method.response.header.Access-Control-Allow-Origin"  = true
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

  # aws_api_gateway_resource.resource will be created
  + resource "aws_api_gateway_resource" "resource" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "register"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.api will be created
  + resource "aws_api_gateway_rest_api" "api" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = "Allow to register user for sending notifications later"
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = -1
      + name                         = "mtchoun-mouh-fix-tro-user registration"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags                         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                     = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }

      + endpoint_configuration {
          + types            = [
              + "REGIONAL",
            ]
          + vpc_endpoint_ids = (known after apply)
        }
    }

  # aws_cloudwatch_event_rule.scheduler will be created
  + resource "aws_cloudwatch_event_rule" "scheduler" {
      + arn                 = (known after apply)
      + description         = "extract image - verify passport is out - send notifications"
      + event_bus_name      = "default"
      + id                  = (known after apply)
      + is_enabled          = true
      + name                = "mtchoun-mouh-fix-tro-trigger_user_scan"
      + name_prefix         = (known after apply)
      + schedule_expression = "cron(0 8 ? * MON-FRI *)"
      + tags                = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all            = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
    }

  # aws_cloudwatch_event_target.target will be created
  + resource "aws_cloudwatch_event_target" "target" {
      + arn            = (known after apply)
      + event_bus_name = "default"
      + id             = (known after apply)
      + rule           = "mtchoun-mouh-fix-tro-trigger_user_scan"
      + target_id      = "lambda"
    }

  # aws_dynamodb_table.Link_table will be created
  + resource "aws_dynamodb_table" "Link_table" {
      + arn              = (known after apply)
      + billing_mode     = "PAY_PER_REQUEST"
      + hash_key         = "link"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Link_table"
      + read_capacity    = 3
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "link"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_dynamodb_table.Register will be created
  + resource "aws_dynamodb_table" "Register" {
      + arn              = (known after apply)
      + billing_mode     = "PROVISIONED"
      + hash_key         = "Name"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Register"
      + read_capacity    = 1
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "Name"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_dynamodb_table.Users will be created
  + resource "aws_dynamodb_table" "Users" {
      + arn              = (known after apply)
      + billing_mode     = "PROVISIONED"
      + hash_key         = "UserName"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Users"
      + read_capacity    = 1
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "UserName"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_lambda_function.lambda will be created
  + resource "aws_lambda_function" "lambda" {
      + arn                            = (known after apply)
      + filename                       = "api/lambda.zip"
      + function_name                  = "mtchoun-mouh-fix-tro-user_registration_consulcam"
      + handler                        = "lambda.register_handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + layers                         = (known after apply)
      + memory_size                    = 128
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = "arn:aws:iam::053932140667:role/website-deployer"
      + runtime                        = "python3.8"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + source_code_hash               = "aG/693OgtesclFbtQG3JpowPoOxVEki6ETbi5wlrhnw="
      + source_code_size               = (known after apply)
      + tags                           = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                       = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + timeout                        = 10
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "API_KEY"         = (sensitive value)
              + "BUCKET_NAME"     = "mtchoun-mouh-fix-tro-djansang"
              + "ENV"             = "mtchoun-mouh-fix-tro"
              + "LINKS_TABLE"     = "mtchoun-mouh-fix-tro-Link_table"
              + "MAINTAINER_MAIL" = (sensitive value)
              + "REGION"          = "eu-central-1"
              + "REGISTERS_TABLE" = "mtchoun-mouh-fix-tro-Register"
              + "SENTRY_DNS"      = (sensitive value)
              + "USERS_TABLE"     = "mtchoun-mouh-fix-tro-Users"
            }
        }

      + tracing_config (known after apply)
    }

  # aws_lambda_function.scan will be created
  + resource "aws_lambda_function" "scan" {
      + arn                            = (known after apply)
      + filename                       = "api/lambda.zip"
      + function_name                  = "mtchoun-mouh-fix-tro-scan_user_consulcam"
      + handler                        = "lambda.scan_handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 128
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = "arn:aws:iam::053932140667:role/website-deployer"
      + runtime                        = "python3.8"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + source_code_hash               = "aG/693OgtesclFbtQG3JpowPoOxVEki6ETbi5wlrhnw="
      + source_code_size               = (known after apply)
      + tags                           = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                       = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "API_KEY"         = (sensitive value)
              + "BUCKET_NAME"     = "mtchoun-mouh-fix-tro-djansang"
              + "ENV"             = "mtchoun-mouh-fix-tro"
              + "LINKS_TABLE"     = "mtchoun-mouh-fix-tro-Link_table"
              + "MAINTAINER_MAIL" = (sensitive value)
              + "REGION"          = "eu-central-1"
              + "REGISTERS_TABLE" = "mtchoun-mouh-fix-tro-Register"
              + "SENTRY_DNS"      = (sensitive value)
              + "USERS_TABLE"     = "mtchoun-mouh-fix-tro-Users"
            }
        }

      + tracing_config (known after apply)
    }

  # aws_lambda_layer_version.test_lambda_layer will be created
  + resource "aws_lambda_layer_version" "test_lambda_layer" {
      + arn                         = (known after apply)
      + compatible_runtimes         = [
          + "python3.7",
          + "python3.8",
        ]
      + created_date                = (known after apply)
      + filename                    = "make_lamda_layer/python.zip"
      + id                          = (known after apply)
      + layer_arn                   = (known after apply)
      + layer_name                  = "test_lambda_layer"
      + signing_job_arn             = (known after apply)
      + signing_profile_version_arn = (known after apply)
      + source_code_hash            = (known after apply)
      + source_code_size            = (known after apply)
      + version                     = (known after apply)
    }

  # aws_lambda_permission.allow_cloudwatch_to_call_check_foo will be created
  + resource "aws_lambda_permission" "allow_cloudwatch_to_call_check_foo" {
      + action        = "lambda:InvokeFunction"
      + function_name = "mtchoun-mouh-fix-tro-scan_user_consulcam"
      + id            = (known after apply)
      + principal     = "events.amazonaws.com"
      + source_arn    = (known after apply)
      + statement_id  = "AllowExecutionFromCloudWatch"
    }

  # aws_lambda_permission.apigw_lambda will be created
  + resource "aws_lambda_permission" "apigw_lambda" {
      + action        = "lambda:InvokeFunction"
      + function_name = "mtchoun-mouh-fix-tro-user_registration_consulcam"
      + id            = (known after apply)
      + principal     = "apigateway.amazonaws.com"
      + source_arn    = (known after apply)
      + statement_id  = "AllowExecutionFromAPIGateway"
    }

  # aws_s3_bucket.images will be created
  + resource "aws_s3_bucket" "images" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "mtchoun-mouh-fix-tro-djansang"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = true
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "Name"        = "images"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                    = {
          + "Name"        = "images"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + versioning (known after apply)
    }

  # aws_s3_bucket.website will be created
  + resource "aws_s3_bucket" "website" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = true
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "Name"        = "Website"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                    = {
          + "Name"        = "Website"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule {
          + allowed_headers = [
              + "*",
            ]
          + allowed_methods = [
              + "PUT",
              + "POST",
              + "GET",
            ]
          + allowed_origins = [
              + "*",
            ]
        }

      + versioning (known after apply)

      + website {
          + error_document = "error.html"
          + index_document = "index.html"
        }
    }

  # aws_s3_bucket_object.example_file will be created
  + resource "aws_s3_bucket_object" "example_file" {
      + acl                    = "private"
      + bucket                 = (known after apply)
      + bucket_key_enabled     = (known after apply)
      + content_type           = "text/html"
      + etag                   = (known after apply)
      + force_destroy          = false
      + id                     = (known after apply)
      + key                    = "index.html"
      + kms_key_id             = (known after apply)
      + server_side_encryption = (known after apply)
      + source                 = "../html/index.html"
      + storage_class          = (known after apply)
      + tags_all               = (known after apply)
      + version_id             = (known after apply)
    }

  # aws_s3_bucket_policy.website will be created
  + resource "aws_s3_bucket_policy" "website" {
      + bucket = (known after apply)
      + id     = (known after apply)
      + policy = (known after apply)
    }

  # aws_s3_bucket_public_access_block.website will be created
  + resource "aws_s3_bucket_public_access_block" "website" {
      + block_public_acls       = false
      + block_public_policy     = false
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = false
      + restrict_public_buckets = false
    }

  # local_file.index_page will be created
  + resource "local_file" "index_page" {
      + content              = (sensitive value)
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "../html/index.html"
      + id                   = (known after apply)
    }

  # module.cors.aws_api_gateway_integration._ will be created
  + resource "aws_api_gateway_integration" "_" {
      + cache_namespace      = (known after apply)
      + connection_type      = "INTERNET"
      + content_handling     = "CONVERT_TO_TEXT"
      + http_method          = "OPTIONS"
      + id                   = (known after apply)
      + passthrough_behavior = (known after apply)
      + request_templates    = {
          + "application/json" = jsonencode(
                {
                  + statusCode = 200
                }
            )
        }
      + resource_id          = (known after apply)
      + rest_api_id          = (known after apply)
      + timeout_milliseconds = 29000
      + type                 = "MOCK"
    }

  # module.cors.aws_api_gateway_integration_response._ will be created
  + resource "aws_api_gateway_integration_response" "_" {
      + http_method         = "OPTIONS"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = "'Authorization,Content-Type,X-Amz-Date,X-Amz-Security-Token,X-Api-Key'"
          + "method.response.header.Access-Control-Allow-Methods" = "'OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE'"
          + "method.response.header.Access-Control-Allow-Origin"  = "'*'"
          + "method.response.header.Access-Control-Max-Age"       = "'7200'"
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

  # module.cors.aws_api_gateway_method._ will be created
  + resource "aws_api_gateway_method" "_" {
      + api_key_required = false
      + authorization    = "NONE"
      + http_method      = "OPTIONS"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # module.cors.aws_api_gateway_method_response._ will be created
  + resource "aws_api_gateway_method_response" "_" {
      + http_method         = "OPTIONS"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_models     = {
          + "application/json" = "Empty"
        }
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = true
          + "method.response.header.Access-Control-Allow-Methods" = true
          + "method.response.header.Access-Control-Allow-Origin"  = true
          + "method.response.header.Access-Control-Max-Age"       = true
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

Plan: 26 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + register_table = "mtchoun-mouh-fix-tro-Register"
  + stage_url      = (known after apply)
  + website_url    = (known after apply)

@billmetangmo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Apply Succeeded

CI link

Apply complete! Resources: 26 added, 0 changed, 0 destroyed.
Details (Click me)
Running apply in the remote backend. Output will stream here. Pressing Ctrl-C
will cancel the remote apply if it's still pending. If the apply started it
will stop streaming the logs, but will not stop the apply running remotely.

Preparing the remote apply...

To view this run in a browser, visit:
https://app.terraform.io/app/tfc-mongulu-cm/mtchoun-mouh-fix-tro/runs/run-3Wdsxmw7jW5v11SX

Waiting for the plan to start...

Terraform v1.9.5
on linux_amd64
Initializing plugins and modules...
data.archive_file.lambda_zip: Reading...
data.archive_file.lambda_zip: Read complete after 0s [id=a302387976ce74579a87a903dcc6149f70895053]
data.aws_caller_identity.current: Reading...
data.aws_iam_role.role: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=053932140667]
data.aws_iam_role.role: Read complete after 0s [id=website-deployer]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_deployment.test will be created
  + resource "aws_api_gateway_deployment" "test" {
      + 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    = "mtchoun-mouh-fix-tro-dev"
    }

  # aws_api_gateway_integration.integration will be created
  + resource "aws_api_gateway_integration" "integration" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + 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.method will be created
  + resource "aws_api_gateway_method" "method" {
      + api_key_required = false
      + authorization    = "NONE"
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_method_response.method_response_200 will be created
  + resource "aws_api_gateway_method_response" "method_response_200" {
      + http_method         = "POST"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = true
          + "method.response.header.Access-Control-Allow-Methods" = false
          + "method.response.header.Access-Control-Allow-Origin"  = true
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

  # aws_api_gateway_resource.resource will be created
  + resource "aws_api_gateway_resource" "resource" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "register"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.api will be created
  + resource "aws_api_gateway_rest_api" "api" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = "Allow to register user for sending notifications later"
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = -1
      + name                         = "mtchoun-mouh-fix-tro-user registration"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags                         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                     = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }

      + endpoint_configuration {
          + types            = [
              + "REGIONAL",
            ]
          + vpc_endpoint_ids = (known after apply)
        }
    }

  # aws_cloudwatch_event_rule.scheduler will be created
  + resource "aws_cloudwatch_event_rule" "scheduler" {
      + arn                 = (known after apply)
      + description         = "extract image - verify passport is out - send notifications"
      + event_bus_name      = "default"
      + id                  = (known after apply)
      + is_enabled          = true
      + name                = "mtchoun-mouh-fix-tro-trigger_user_scan"
      + name_prefix         = (known after apply)
      + schedule_expression = "cron(0 8 ? * MON-FRI *)"
      + tags                = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all            = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
    }

  # aws_cloudwatch_event_target.target will be created
  + resource "aws_cloudwatch_event_target" "target" {
      + arn            = (known after apply)
      + event_bus_name = "default"
      + id             = (known after apply)
      + rule           = "mtchoun-mouh-fix-tro-trigger_user_scan"
      + target_id      = "lambda"
    }

  # aws_dynamodb_table.Link_table will be created
  + resource "aws_dynamodb_table" "Link_table" {
      + arn              = (known after apply)
      + billing_mode     = "PAY_PER_REQUEST"
      + hash_key         = "link"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Link_table"
      + read_capacity    = 3
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "link"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_dynamodb_table.Register will be created
  + resource "aws_dynamodb_table" "Register" {
      + arn              = (known after apply)
      + billing_mode     = "PROVISIONED"
      + hash_key         = "Name"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Register"
      + read_capacity    = 1
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "Name"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_dynamodb_table.Users will be created
  + resource "aws_dynamodb_table" "Users" {
      + arn              = (known after apply)
      + billing_mode     = "PROVISIONED"
      + hash_key         = "UserName"
      + id               = (known after apply)
      + name             = "mtchoun-mouh-fix-tro-Users"
      + read_capacity    = 1
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags             = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all         = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + write_capacity   = 1

      + attribute {
          + name = "UserName"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = false
        }

      + server_side_encryption (known after apply)
    }

  # aws_lambda_function.lambda will be created
  + resource "aws_lambda_function" "lambda" {
      + arn                            = (known after apply)
      + filename                       = "api/lambda.zip"
      + function_name                  = "mtchoun-mouh-fix-tro-user_registration_consulcam"
      + handler                        = "lambda.register_handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + layers                         = (known after apply)
      + memory_size                    = 128
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = "arn:aws:iam::053932140667:role/website-deployer"
      + runtime                        = "python3.8"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + source_code_hash               = "aG/693OgtesclFbtQG3JpowPoOxVEki6ETbi5wlrhnw="
      + source_code_size               = (known after apply)
      + tags                           = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                       = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + timeout                        = 10
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "API_KEY"         = (sensitive value)
              + "BUCKET_NAME"     = "mtchoun-mouh-fix-tro-djansang"
              + "ENV"             = "mtchoun-mouh-fix-tro"
              + "LINKS_TABLE"     = "mtchoun-mouh-fix-tro-Link_table"
              + "MAINTAINER_MAIL" = (sensitive value)
              + "REGION"          = "eu-central-1"
              + "REGISTERS_TABLE" = "mtchoun-mouh-fix-tro-Register"
              + "SENTRY_DNS"      = (sensitive value)
              + "USERS_TABLE"     = "mtchoun-mouh-fix-tro-Users"
            }
        }

      + tracing_config (known after apply)
    }

  # aws_lambda_function.scan will be created
  + resource "aws_lambda_function" "scan" {
      + arn                            = (known after apply)
      + filename                       = "api/lambda.zip"
      + function_name                  = "mtchoun-mouh-fix-tro-scan_user_consulcam"
      + handler                        = "lambda.scan_handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 128
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = "arn:aws:iam::053932140667:role/website-deployer"
      + runtime                        = "python3.8"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + source_code_hash               = "aG/693OgtesclFbtQG3JpowPoOxVEki6ETbi5wlrhnw="
      + source_code_size               = (known after apply)
      + tags                           = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                       = {
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "API_KEY"         = (sensitive value)
              + "BUCKET_NAME"     = "mtchoun-mouh-fix-tro-djansang"
              + "ENV"             = "mtchoun-mouh-fix-tro"
              + "LINKS_TABLE"     = "mtchoun-mouh-fix-tro-Link_table"
              + "MAINTAINER_MAIL" = (sensitive value)
              + "REGION"          = "eu-central-1"
              + "REGISTERS_TABLE" = "mtchoun-mouh-fix-tro-Register"
              + "SENTRY_DNS"      = (sensitive value)
              + "USERS_TABLE"     = "mtchoun-mouh-fix-tro-Users"
            }
        }

      + tracing_config (known after apply)
    }

  # aws_lambda_layer_version.test_lambda_layer will be created
  + resource "aws_lambda_layer_version" "test_lambda_layer" {
      + arn                         = (known after apply)
      + compatible_runtimes         = [
          + "python3.7",
          + "python3.8",
        ]
      + created_date                = (known after apply)
      + filename                    = "make_lamda_layer/python.zip"
      + id                          = (known after apply)
      + layer_arn                   = (known after apply)
      + layer_name                  = "test_lambda_layer"
      + signing_job_arn             = (known after apply)
      + signing_profile_version_arn = (known after apply)
      + source_code_hash            = (known after apply)
      + source_code_size            = (known after apply)
      + version                     = (known after apply)
    }

  # aws_lambda_permission.allow_cloudwatch_to_call_check_foo will be created
  + resource "aws_lambda_permission" "allow_cloudwatch_to_call_check_foo" {
      + action        = "lambda:InvokeFunction"
      + function_name = "mtchoun-mouh-fix-tro-scan_user_consulcam"
      + id            = (known after apply)
      + principal     = "events.amazonaws.com"
      + source_arn    = (known after apply)
      + statement_id  = "AllowExecutionFromCloudWatch"
    }

  # aws_lambda_permission.apigw_lambda will be created
  + resource "aws_lambda_permission" "apigw_lambda" {
      + action        = "lambda:InvokeFunction"
      + function_name = "mtchoun-mouh-fix-tro-user_registration_consulcam"
      + id            = (known after apply)
      + principal     = "apigateway.amazonaws.com"
      + source_arn    = (known after apply)
      + statement_id  = "AllowExecutionFromAPIGateway"
    }

  # aws_s3_bucket.images will be created
  + resource "aws_s3_bucket" "images" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "mtchoun-mouh-fix-tro-djansang"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = true
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "Name"        = "images"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                    = {
          + "Name"        = "images"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + versioning (known after apply)
    }

  # aws_s3_bucket.website will be created
  + resource "aws_s3_bucket" "website" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = true
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "Name"        = "Website"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + tags_all                    = {
          + "Name"        = "Website"
          + "environment" = "mtchoun-mouh-master"
          + "project"     = "mtchoun-mouh"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule {
          + allowed_headers = [
              + "*",
            ]
          + allowed_methods = [
              + "PUT",
              + "POST",
              + "GET",
            ]
          + allowed_origins = [
              + "*",
            ]
        }

      + versioning (known after apply)

      + website {
          + error_document = "error.html"
          + index_document = "index.html"
        }
    }

  # aws_s3_bucket_object.example_file will be created
  + resource "aws_s3_bucket_object" "example_file" {
      + acl                    = "private"
      + bucket                 = (known after apply)
      + bucket_key_enabled     = (known after apply)
      + content_type           = "text/html"
      + etag                   = (known after apply)
      + force_destroy          = false
      + id                     = (known after apply)
      + key                    = "index.html"
      + kms_key_id             = (known after apply)
      + server_side_encryption = (known after apply)
      + source                 = "../html/index.html"
      + storage_class          = (known after apply)
      + tags_all               = (known after apply)
      + version_id             = (known after apply)
    }

  # aws_s3_bucket_policy.website will be created
  + resource "aws_s3_bucket_policy" "website" {
      + bucket = (known after apply)
      + id     = (known after apply)
      + policy = (known after apply)
    }

  # aws_s3_bucket_public_access_block.website will be created
  + resource "aws_s3_bucket_public_access_block" "website" {
      + block_public_acls       = false
      + block_public_policy     = false
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = false
      + restrict_public_buckets = false
    }

  # local_file.index_page will be created
  + resource "local_file" "index_page" {
      + content              = (sensitive value)
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "../html/index.html"
      + id                   = (known after apply)
    }

  # module.cors.aws_api_gateway_integration._ will be created
  + resource "aws_api_gateway_integration" "_" {
      + cache_namespace      = (known after apply)
      + connection_type      = "INTERNET"
      + content_handling     = "CONVERT_TO_TEXT"
      + http_method          = "OPTIONS"
      + id                   = (known after apply)
      + passthrough_behavior = (known after apply)
      + request_templates    = {
          + "application/json" = jsonencode(
                {
                  + statusCode = 200
                }
            )
        }
      + resource_id          = (known after apply)
      + rest_api_id          = (known after apply)
      + timeout_milliseconds = 29000
      + type                 = "MOCK"
    }

  # module.cors.aws_api_gateway_integration_response._ will be created
  + resource "aws_api_gateway_integration_response" "_" {
      + http_method         = "OPTIONS"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = "'Authorization,Content-Type,X-Amz-Date,X-Amz-Security-Token,X-Api-Key'"
          + "method.response.header.Access-Control-Allow-Methods" = "'OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE'"
          + "method.response.header.Access-Control-Allow-Origin"  = "'*'"
          + "method.response.header.Access-Control-Max-Age"       = "'7200'"
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

  # module.cors.aws_api_gateway_method._ will be created
  + resource "aws_api_gateway_method" "_" {
      + api_key_required = false
      + authorization    = "NONE"
      + http_method      = "OPTIONS"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # module.cors.aws_api_gateway_method_response._ will be created
  + resource "aws_api_gateway_method_response" "_" {
      + http_method         = "OPTIONS"
      + id                  = (known after apply)
      + resource_id         = (known after apply)
      + response_models     = {
          + "application/json" = "Empty"
        }
      + response_parameters = {
          + "method.response.header.Access-Control-Allow-Headers" = true
          + "method.response.header.Access-Control-Allow-Methods" = true
          + "method.response.header.Access-Control-Allow-Origin"  = true
          + "method.response.header.Access-Control-Max-Age"       = true
        }
      + rest_api_id         = (known after apply)
      + status_code         = "200"
    }

Plan: 26 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + register_table = "mtchoun-mouh-fix-tro-Register"
  + stage_url      = (known after apply)
  + website_url    = (known after apply)

------------------------------------------------------------------------

Cost estimation:

Resources: 3 of 5 estimated
           $1.872/mo +$1.872

------------------------------------------------------------------------

aws_dynamodb_table.Register: Creating...
aws_dynamodb_table.Users: Creating...
aws_api_gateway_rest_api.api: Creating...
aws_cloudwatch_event_rule.scheduler: Creating...
aws_dynamodb_table.Link_table: Creating...
aws_lambda_layer_version.test_lambda_layer: Creating...
aws_s3_bucket.images: Creating...
aws_lambda_function.scan: Creating...
aws_s3_bucket.website: Creating...
aws_cloudwatch_event_rule.scheduler: Creation complete after 1s [id=mtchoun-mouh-fix-tro-trigger_user_scan]
aws_api_gateway_rest_api.api: Creation complete after 1s [id=cp2o0cf4qg]
aws_api_gateway_resource.resource: Creating...
aws_api_gateway_resource.resource: Creation complete after 1s [id=ndmxx2]
aws_api_gateway_method.method: Creating...
module.cors.aws_api_gateway_method._: Creating...
module.cors.aws_api_gateway_method._: Creation complete after 0s [id=agm-cp2o0cf4qg-ndmxx2-OPTIONS]
module.cors.aws_api_gateway_method_response._: Creating...
module.cors.aws_api_gateway_integration._: Creating...
aws_api_gateway_method.method: Creation complete after 0s [id=agm-cp2o0cf4qg-ndmxx2-POST]
aws_api_gateway_method_response.method_response_200: Creating...
module.cors.aws_api_gateway_method_response._: Creation complete after 0s [id=agmr-cp2o0cf4qg-ndmxx2-OPTIONS-200]
module.cors.aws_api_gateway_integration._: Creation complete after 1s [id=agi-cp2o0cf4qg-ndmxx2-OPTIONS]
module.cors.aws_api_gateway_integration_response._: Creating...
aws_api_gateway_method_response.method_response_200: Creation complete after 1s [id=agmr-cp2o0cf4qg-ndmxx2-POST-200]
module.cors.aws_api_gateway_integration_response._: Creation complete after 0s [id=agir-cp2o0cf4qg-ndmxx2-OPTIONS-200]
aws_s3_bucket.images: Creation complete after 6s [id=mtchoun-mouh-fix-tro-djansang]
aws_lambda_function.scan: Creation complete after 7s [id=mtchoun-mouh-fix-tro-scan_user_consulcam]
aws_lambda_permission.allow_cloudwatch_to_call_check_foo: Creating...
aws_cloudwatch_event_target.target: Creating...
aws_lambda_permission.allow_cloudwatch_to_call_check_foo: Creation complete after 1s [id=AllowExecutionFromCloudWatch]
aws_cloudwatch_event_target.target: Creation complete after 1s [id=mtchoun-mouh-fix-tro-trigger_user_scan-lambda]
aws_s3_bucket.website: Creation complete after 8s [id=mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm]
aws_s3_bucket_public_access_block.website: Creating...
aws_s3_bucket_public_access_block.website: Creation complete after 1s [id=mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm]
aws_s3_bucket_policy.website: Creating...
aws_dynamodb_table.Register: Creation complete after 9s [id=mtchoun-mouh-fix-tro-Register]
aws_dynamodb_table.Link_table: Creation complete after 9s [id=mtchoun-mouh-fix-tro-Link_table]
aws_dynamodb_table.Users: Creation complete after 9s [id=mtchoun-mouh-fix-tro-Users]
aws_s3_bucket_policy.website: Creation complete after 0s [id=mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm]
aws_lambda_layer_version.test_lambda_layer: Still creating... [10s elapsed]
aws_lambda_layer_version.test_lambda_layer: Creation complete after 12s [id=arn:aws:lambda:eu-central-1:053932140667:layer:test_lambda_layer:7]
aws_lambda_function.lambda: Creating...
aws_lambda_function.lambda: Creation complete after 7s [id=mtchoun-mouh-fix-tro-user_registration_consulcam]
aws_lambda_permission.apigw_lambda: Creating...
aws_api_gateway_integration.integration: Creating...
aws_api_gateway_integration.integration: Creation complete after 0s [id=agi-cp2o0cf4qg-ndmxx2-POST]
aws_api_gateway_deployment.test: Creating...
aws_lambda_permission.apigw_lambda: Creation complete after 0s [id=AllowExecutionFromAPIGateway]
aws_api_gateway_deployment.test: Creation complete after 1s [id=v1qcu0]
local_file.index_page: Creating...
local_file.index_page: Creation complete after 0s [id=b80b6b5afb6af57684ce6c981b9905b72fddf92d]
aws_s3_bucket_object.example_file: Creating...
aws_s3_bucket_object.example_file: Creation complete after 2s [id=index.html]

Apply complete! Resources: 26 added, 0 changed, 0 destroyed.

Outputs:

register_table = "mtchoun-mouh-fix-tro-Register"
stage_url = "https://cp2o0cf4qg.execute-api.eu-central-1.amazonaws.com/mtchoun-mouh-fix-tro-dev"
website_url = "http://mtchoun-mouh-fix-tro-mtchoun-mouh.mongulu.cm.s3-website.eu-central-1.amazonaws.com"

Please sign in to comment.