Skip to content

Create lambda with proper config, image, gateway, permissions#3

Merged
ana-sher merged 3 commits into
mainfrom
dev
Nov 28, 2025
Merged

Create lambda with proper config, image, gateway, permissions#3
ana-sher merged 3 commits into
mainfrom
dev

Conversation

@ana-sher

Copy link
Copy Markdown
Owner

No description provided.

@ana-sher ana-sher self-assigned this Nov 28, 2025
@ana-sher ana-sher added the enhancement New feature or request label Nov 28, 2025
@github-actions

Copy link
Copy Markdown

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖failure

Show Plan
data.archive_file.docker_context: Reading...
data.archive_file.docker_context: Read complete after 0s [id=faa95f0ae5347474de6e7c17827f0e10f031a48e]
null_resource.cleanup_zip: Refreshing state... [id=1970654351978712394]
module.aws_lambda_function.data.aws_region.current: Reading...
data.aws_ecr_authorization_token.token: Reading...
module.aws_lambda_function.data.aws_caller_identity.current: Reading...
module.aws_lambda_function.data.aws_partition.current: Reading...
aws_apigatewayv2_api.api: Refreshing state... [id=040fg458ka]
module.docker_image.data.aws_caller_identity.this: Reading...
data.aws_caller_identity.current: Reading...
module.docker_image.data.aws_region.current: Reading...
module.docker_image.aws_ecr_repository.this[0]: Refreshing state... [id=climate-analysis]
aws_s3_bucket.app_s3: Refreshing state... [id=climate-analysis-bucket]
module.aws_lambda_function.data.aws_region.current: Read complete after 1s [id=eu-north-1]
module.docker_image.data.aws_region.current: Read complete after 1s [id=eu-north-1]
module.aws_lambda_function.data.aws_partition.current: Read complete after 1s [id=aws]
module.aws_lambda_function.aws_cloudwatch_log_group.lambda[0]: Refreshing state... [id=/aws/lambda/climate_analysis_lambda]
aws_iam_role.app_role: Refreshing state... [id=climate_app_role]
module.aws_lambda_function.data.aws_caller_identity.current: Read complete after 1s [id=266796786618]
data.aws_caller_identity.current: Read complete after 1s [id=266796786618]
module.docker_image.data.aws_caller_identity.this: Read complete after 1s [id=266796786618]
aws_iam_role_policy_attachment.ecs_read: Refreshing state... [id=climate_app_role/arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly]
aws_iam_role_policy_attachment.lambda_basic: Refreshing state... [id=climate_app_role/arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
aws_apigatewayv2_stage.default_stage: Refreshing state... [id=$default]
data.aws_ecr_authorization_token.token: Read complete after 1s [id=eu-north-1]
module.docker_image.aws_ecr_lifecycle_policy.this[0]: Refreshing state... [id=climate-analysis]
module.docker_image.docker_image.this: Refreshing state... [id=sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9]
module.docker_image.docker_registry_image.this: Refreshing state... [id=sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0]
module.aws_lambda_function.aws_lambda_function.this[0]: Refreshing state... [id=climate_analysis_lambda]
aws_lambda_permission.apigw_invoke: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_apigatewayv2_integration.lambda_integration: Refreshing state... [id=a4fgymd]
aws_apigatewayv2_route.root_route: Refreshing state... [id=i3s6lws]
aws_s3_bucket_public_access_block.s3_access: Refreshing state... [id=climate-analysis-bucket]
data.aws_iam_policy_document.aws_policy_doc: Reading...
data.aws_iam_policy_document.aws_policy_doc: Read complete after 0s [id=1638820244]
aws_iam_policy.policy: Refreshing state... [id=arn:aws:iam::266796786618:policy/climate_analysis_resources_policy]
aws_iam_role_policy_attachment.app_role_policy_attach: Refreshing state... [id=climate_app_role/arn:aws:iam::266796786618:policy/climate_analysis_resources_policy]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the
last "terraform apply" which may have affected this plan:

  # module.docker_image.docker_image.this has been deleted
  - resource "docker_image" "this" {
        id           = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9"
      - image_id     = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> null
      - name         = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> null
        # (3 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
-/+ destroy and then create replacement
+/- create replacement and then destroy

Terraform planned the following actions, but then encountered a problem:

  # null_resource.cleanup_zip is tainted, so must be replaced
-/+ resource "null_resource" "cleanup_zip" {
      ~ id       = "1970654351978712394" -> (known after apply)
      ~ triggers = {
          ~ "docker_tag" = "SnCVQOL2mzo9" -> "BSNUTlx9+cEi"
        }
    }

  # module.aws_lambda_function.aws_lambda_function.this[0] will be updated in-place
  ~ resource "aws_lambda_function" "this" {
        id                             = "climate_analysis_lambda"
      ~ image_uri                      = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi"
      ~ last_modified                  = "2025-11-28T16:02:33.000+0000" -> (known after apply)
        tags                           = {
            "terraform-aws-modules" = "lambda"
        }
        # (28 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

  # module.docker_image.docker_image.this will be created
  + resource "docker_image" "this" {
      + force_remove = false
      + id           = (known after apply)
      + image_id     = (known after apply)
      + keep_locally = false
      + name         = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi"
      + repo_digest  = (known after apply)

      + build {
          + cache_from     = []
          + context        = "../"
          + dockerfile     = "Dockerfile"
          + extra_hosts    = []
          + remove         = true
          + security_opt   = []
          + tag            = []
            # (13 unchanged attributes hidden)
        }
    }

  # module.docker_image.docker_registry_image.this must be replaced
+/- resource "docker_registry_image" "this" {
      ~ id                   = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> (known after apply)
      ~ name                 = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi" # forces replacement
      ~ sha256_digest        = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> (known after apply)
      ~ triggers             = {
          - "image_id" = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0"
        } -> (known after apply) # forces replacement
        # (2 unchanged attributes hidden)
    }

Plan: 3 to add, 1 to change, 2 to destroy.
Releasing state lock. This may take a few moments...

Pusher: @ana-sher, Action: pull_request

@github-actions

Copy link
Copy Markdown

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Show Plan
data.archive_file.docker_context: Reading...
data.archive_file.docker_context: Read complete after 0s [id=faa95f0ae5347474de6e7c17827f0e10f031a48e]
null_resource.cleanup_zip: Refreshing state... [id=1970654351978712394]
module.docker_image.data.aws_region.current: Reading...
module.aws_lambda_function.data.aws_partition.current: Reading...
module.docker_image.data.aws_caller_identity.this: Reading...
aws_apigatewayv2_api.api: Refreshing state... [id=040fg458ka]
module.aws_lambda_function.aws_cloudwatch_log_group.lambda[0]: Refreshing state... [id=/aws/lambda/climate_analysis_lambda]
data.aws_ecr_authorization_token.token: Reading...
module.aws_lambda_function.data.aws_region.current: Reading...
data.aws_caller_identity.current: Reading...
aws_iam_role.app_role: Refreshing state... [id=climate_app_role]
aws_s3_bucket.app_s3: Refreshing state... [id=climate-analysis-bucket]
module.aws_lambda_function.data.aws_partition.current: Read complete after 0s [id=aws]
module.aws_lambda_function.data.aws_region.current: Read complete after 0s [id=eu-north-1]
module.docker_image.data.aws_region.current: Read complete after 0s [id=eu-north-1]
module.docker_image.aws_ecr_repository.this[0]: Refreshing state... [id=climate-analysis]
module.aws_lambda_function.data.aws_caller_identity.current: Reading...
module.docker_image.data.aws_caller_identity.this: Read complete after 0s [id=266796786618]
aws_iam_role_policy_attachment.ecs_read: Refreshing state... [id=climate_app_role/arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly]
aws_iam_role_policy_attachment.lambda_basic: Refreshing state... [id=climate_app_role/arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
data.aws_caller_identity.current: Read complete after 0s [id=266796786618]
module.aws_lambda_function.data.aws_caller_identity.current: Read complete after 1s [id=266796786618]
aws_apigatewayv2_stage.default_stage: Refreshing state... [id=$default]
data.aws_ecr_authorization_token.token: Read complete after 1s [id=eu-north-1]
module.docker_image.aws_ecr_lifecycle_policy.this[0]: Refreshing state... [id=climate-analysis]
module.docker_image.docker_image.this: Refreshing state... [id=sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9]
module.docker_image.docker_registry_image.this: Refreshing state... [id=sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0]
module.aws_lambda_function.aws_lambda_function.this[0]: Refreshing state... [id=climate_analysis_lambda]
aws_lambda_permission.apigw_invoke: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_apigatewayv2_integration.lambda_integration: Refreshing state... [id=a4fgymd]
aws_apigatewayv2_route.root_route: Refreshing state... [id=i3s6lws]
aws_s3_bucket_public_access_block.s3_access: Refreshing state... [id=climate-analysis-bucket]
data.aws_iam_policy_document.aws_policy_doc: Reading...
data.aws_iam_policy_document.aws_policy_doc: Read complete after 0s [id=1638820244]
aws_iam_policy.policy: Refreshing state... [id=arn:aws:iam::266796786618:policy/climate_analysis_resources_policy]
aws_iam_role_policy_attachment.app_role_policy_attach: Refreshing state... [id=climate_app_role/arn:aws:iam::266796786618:policy/climate_analysis_resources_policy]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the
last "terraform apply" which may have affected this plan:

  # module.docker_image.docker_image.this has been deleted
  - resource "docker_image" "this" {
        id           = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9"
      - image_id     = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> null
      - name         = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> null
        # (3 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
-/+ destroy and then create replacement
+/- create replacement and then destroy

Terraform will perform the following actions:

  # null_resource.cleanup_zip is tainted, so must be replaced
-/+ resource "null_resource" "cleanup_zip" {
      ~ id       = "1970654351978712394" -> (known after apply)
      ~ triggers = {
          ~ "docker_tag" = "SnCVQOL2mzo9" -> "BSNUTlx9+cEi"
        }
    }

  # module.aws_lambda_function.aws_lambda_function.this[0] will be updated in-place
  ~ resource "aws_lambda_function" "this" {
        id                             = "climate_analysis_lambda"
      ~ image_uri                      = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi"
      ~ last_modified                  = "2025-11-28T16:02:33.000+0000" -> (known after apply)
        tags                           = {
            "terraform-aws-modules" = "lambda"
        }
        # (28 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

  # module.docker_image.docker_image.this will be created
  + resource "docker_image" "this" {
      + force_remove = false
      + id           = (known after apply)
      + image_id     = (known after apply)
      + keep_locally = false
      + name         = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi"
      + repo_digest  = (known after apply)

      + build {
          + cache_from     = []
          + context        = "../"
          + dockerfile     = "Dockerfile"
          + extra_hosts    = []
          + remove         = true
          + security_opt   = []
          + tag            = []
            # (13 unchanged attributes hidden)
        }
    }

  # module.docker_image.docker_registry_image.this must be replaced
+/- resource "docker_registry_image" "this" {
      ~ id                   = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> (known after apply)
      ~ name                 = "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:SnCVQOL2mzo9" -> "266796786618.dkr.ecr.eu-north-1.amazonaws.com/climate-analysis:BSNUTlx9+cEi" # forces replacement
      ~ sha256_digest        = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0" -> (known after apply)
      ~ triggers             = {
          - "image_id" = "sha256:079d9f471ba237301f89b4120515117e2c76da02f80b736285ea0e08f0a8b6d0"
        } -> (known after apply) # forces replacement
        # (2 unchanged attributes hidden)
    }

Plan: 3 to add, 1 to change, 2 to destroy.

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.

Pusher: @ana-sher, Action: pull_request

@ana-sher ana-sher merged commit 80b660e into main Nov 28, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant