DataDog / datadog-lambda-python

The Datadog AWS Lambda Layer for Python
https://docs.datadoghq.com/integrations/amazon_lambda/#installing-and-using-the-datadog-layer
Apache License 2.0
84 stars 45 forks source link

AWS provider version mismatch #507

Closed sakrlog closed 1 month ago

sakrlog commented 2 months ago

Expected Behavior

I have this config

module "lambda-datadog" {
  source  = "DataDog/lambda-datadog/aws"
  version = "1.3.0"

  providers = {
    aws = aws
  }

  source_code_hash = data.archive_file.indexer_achive.output_base64sha256
  function_name = "example-funtion"
  role          = aws_iam_role.indexer_lambda_exec.arn
  handler       = "main.handler"
  runtime       = "python3.9"
  memory_size   = 1024
  timeout     = 900
  reserved_concurrent_executions = 2

  s3_bucket = "${var.lambda_storage_bucket}"
  s3_key    = aws_s3_object.indexer_file.key

  layers = [aws_lambda_layer_version.my-lambda-layer.arn]

  environment_variables = {
    "DD_API_KEY" : "${var.dd_api_key}"
    "DD_ENV" : "${var.environment_name}"
    "DD_SERVICE" : "lambda"
    "DD_SITE": "datadoghq.com"
    "DD_VERSION" : "1.0.0"
    "ENV" = "${var.environment_name}"
  }

  datadog_extension_layer_version = 58
  datadog_python_layer_version = 97
}

Actual Behavior

│ Error: Failed to query available provider packages │ │ Could not retrieve the list of available versions for provider │ hashicorp/aws: no available releases match the given constraints ~> 5.5.0, │ >= 5.32.0

Steps to Reproduce the Problem

1.Set your aws provider to your required version. example:

 aws = {
      source  = "hashicorp/aws"
      version = "~> 5.5.0"
    }
  1. This module will require aws provider version ="~>5.32.0" which is redundant.

Specifications

Stacktrace

  Paste here
duncanpharvey commented 1 month ago

Hi @sakrlog,

Thanks for reaching out! Requiring >=5.32.0 was an intentional decision to support the available arguments in the aws_lambda_function resource. Relaxing the version requirement in the Terraform module results in the error below, regardless of whether or not the logging_config related arguments are used.

│ Error: Unsupported block type
│ 
│   on ../../main.tf line 178, in resource "aws_lambda_function" "this":
│  178:   dynamic "logging_config" {
│ 
│ Blocks of type "logging_config" are not expected here.

Here's the relevant AWS provider release: https://github.com/hashicorp/terraform-provider-aws/releases/tag/v5.32.0

data-source/aws_lambda_function: Add logging_config attribute

I'm closing out this issue but feel free to reopen it if you have follow up questions or suggestions for a solution that would allow backwards compatibility with older versions of the AWS provider.

Thanks, Duncan