Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform does not accept source_code_hash #28018

Closed
andormarkus opened this issue Mar 8, 2021 · 2 comments
Closed

Terraform does not accept source_code_hash #28018

andormarkus opened this issue Mar 8, 2021 · 2 comments
Labels
bug new new issue not yet triaged provider/aws

Comments

@andormarkus
Copy link
Contributor

andormarkus commented Mar 8, 2021

Hi All,

We are on Terraform 0.14.6 and experiencing the following issue.
We are providing source_code_hash for the aws_lambda_layer_version in the plan terraform accepts it but writes totally different to the state file.

In the plan the source_code_hash is FyN0P9BvuTm023dkHFaWvAGmyD0rlhujGsPCTqaBGyw= however in the state file it becames c3forIEso3mJh74PY6HrhFK94GfJvQ4zG9rEIgBCBhw=.

When I check the layer in AWS CLI the "CodeSha256": c3forIEso3mJh74PY6HrhFK94GfJvQ4zG9rEIgBCBhw=,

Based on this it does not matter what kind of source_code_hash I can not overwrite hash of filename.

TF config.

  resource "aws_lambda_layer_version" "loader" {
  layer_name          = "loader"
  compatible_runtimes = ["python3.8"]

  filename         = "lambda_layer.zip"
  source_code_hash = filebase64sha256("lambda_layer.zip")
}

TF plan looks like this

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

However in the statefile I see the following

  {
      "mode": "managed",
      "type": "aws_lambda_layer_version",
      "name": "loader",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": ":",
            "compatible_runtimes": [
              "python3.8"
            ],
            "created_date": "2021-03-08T23:33:40.408+0000",
            "filename": "lambda_layer.zip",
            "id": "",
            "layer_arn": "",
            "layer_name": "",
            "license_info": "",
            "s3_bucket": null,
            "s3_key": null,
            "s3_object_version": null,
            "signing_job_arn": "",
            "signing_profile_version_arn": "",
            "source_code_hash": "c3forIEso3mJh74PY6HrhFK94GfJvQ4zG9rEIgBCBhw=",
            "source_code_size": 5391195,
            "version": "5"
          },
          "sensitive_attributes": [],
          "private": "bnVsbA==",
          "dependencies": [
            ""
          ]
        }
      ]
    },```
@ghost
Copy link

ghost commented Mar 9, 2021

This issue has been automatically migrated to hashicorp/terraform-provider-aws#17989 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-aws#17989.

@ghost ghost closed this as completed Mar 9, 2021
@ghost
Copy link

ghost commented Apr 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged provider/aws
Projects
None yet
Development

No branches or pull requests

2 participants