terraform-aws-modules / terraform-aws-datadog-forwarders

Terraform module to create resources on AWS to forward logs/metrics to Datadog 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/datadog-forwarders/aws
Apache License 2.0
55 stars 41 forks source link

Number of tags for s3 bucket object #25

Closed alena-volchanskaia closed 1 year ago

alena-volchanskaia commented 1 year ago

Description

The number of tags that can be attached to an s3 bucket object is 10 AWS Documentation For other AWS resources, this limit is 50.

So, in the case when we use more than 10 tags for the whole module we have an error

⚠️ Note

It doesn't depend on terraform. It's AWS limit.

Versions

Providers required by state: provider[registry.terraform.io/hashicorp/aws] provider[registry.terraform.io/hashicorp/null] provider[terraform.io/builtin/terraform]

Reproduction Code [Required]

Steps to reproduce the behavior:

You need also to add more than 10 tags to the variable tags ;

variable "tags" {
  description = "A map of tags to use on all resources"
  type        = map(string)
  default     = {
  "Name.1"="a"
  "Name.2"="a"
  "Name.3"="a"
  "Name.4"="a"
  "Name.5"="a"
  "Name.6"="a"
  "Name.7"="a"
  "Name.8"="a"
  "Name.9"="a"
  "Name.10"="a"
  "Name.11"="a"
}
}

module "datadog_log_forwarder" {
  source  = "terraform-aws-modules/datadog-forwarders/aws//modules/log_forwarder"
  version = "4.1.1"

  dd_api_key = var.dd_api_key
  dd_site = "datadoghq.eu"
  forwarder_version = "3.41.0"

  bucket_name  = "s-dd-forwarder-${var.env}"
  kms_key_arn = var.cmk_arn

  role_tags = var.role_tags
  tags  = var.tags

  environment_variables = { DD_TAGS = "env:cloud-${var.env}" }
}

Expected behavior

The bucket zip object created without any tags

Actual behavior

Now the bucket zip object tags as other AWS resources, but terraform isn't applied if the tags count more than 10

Terminal Output Screenshot(s)

Error: error updating tags: error setting resource tags (s-dd-forwarder-dev/aws-dd-forwarder-3.41.0.zip): BadRequest: Object tags cannot be greater than 10
    status code: 400, request id: TE64412FP9X2M6RM, host id: QshfEqkYz3YB1fcBPsmuqZ1jfFP3a3JegL4W5b+YPqD7Vck3FwZ8nvIewvdg4hrb+HTUdZS3q1I1bjEiZ/ZQBA==
  on .terraform/modules/datadog_log_forwarder/modules/log_forwarder/main.tf line 131, in resource "aws_s3_bucket_object" "this":
 131: resource "aws_s3_bucket_object" "this" {
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

Additional context

-

bryantbiggs commented 1 year ago

I believe the solution here is to avoid prescribing more than 10 tags. How would you propose we resolve this issue for users?

antonbabenko commented 1 year ago

We can introduce another variable just for s3 tags, like here - https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/main.tf#L163

alena-volchanskaia commented 1 year ago

Hi! Would you happen to have any updates/solutions about the issue?

Unfortunately, we can't reduce the number of our tags, because other objects use them for filtering data.

bryantbiggs commented 1 year ago

I think the type of solution that Anton linked to would satisfy this issue - PRs are welcomed

antonbabenko commented 1 year ago

This issue has been resolved in version 5.0.1 :tada:

github-actions[bot] commented 1 year ago

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.