Skip to content

Commit 7cbb68f

Browse files
authored
feat!: Upgrade AWS provider and min required Terraform version to 6.0 and 1.5.7 respectively (#53)
1 parent a083762 commit 7cbb68f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+148
-119
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.96.2
3+
rev: v1.99.5
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs

README.md

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

examples/complete/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ Note that this example may create resources which will incur monetary charges on
2323

2424
| Name | Version |
2525
|------|---------|
26-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
26+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
27+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
2828
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2929

3030
## Providers
3131

3232
| Name | Version |
3333
|------|---------|
34-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
34+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
3535
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
3636

3737
## Modules
3838

3939
| Name | Source | Version |
4040
|------|--------|---------|
4141
| <a name="module_default"></a> [default](#module\_default) | ../../ | n/a |
42-
| <a name="module_log_bucket_1"></a> [log\_bucket\_1](#module\_log\_bucket\_1) | terraform-aws-modules/s3-bucket/aws | ~> 4.0 |
43-
| <a name="module_log_bucket_2"></a> [log\_bucket\_2](#module\_log\_bucket\_2) | terraform-aws-modules/s3-bucket/aws | ~> 4.0 |
42+
| <a name="module_log_bucket_1"></a> [log\_bucket\_1](#module\_log\_bucket\_1) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
43+
| <a name="module_log_bucket_2"></a> [log\_bucket\_2](#module\_log\_bucket\_2) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
4444
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 5.0 |
45-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
46-
| <a name="module_vpc_endpoints"></a> [vpc\_endpoints](#module\_vpc\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 5.0 |
45+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
46+
| <a name="module_vpc_endpoints"></a> [vpc\_endpoints](#module\_vpc\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 6.0 |
4747

4848
## Resources
4949

examples/complete/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ resource "aws_kms_alias" "datadog" {
238238

239239
module "vpc" {
240240
source = "terraform-aws-modules/vpc/aws"
241-
version = "~> 5.0"
241+
version = "~> 6.0"
242242

243243
name = local.name
244244
cidr = local.vpc_cidr
@@ -254,7 +254,7 @@ module "vpc" {
254254

255255
module "vpc_endpoints" {
256256
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
257-
version = "~> 5.0"
257+
version = "~> 6.0"
258258

259259
vpc_id = module.vpc.vpc_id
260260
security_group_ids = [module.security_group.security_group_id]
@@ -306,7 +306,7 @@ module "security_group" {
306306

307307
module "log_bucket_1" {
308308
source = "terraform-aws-modules/s3-bucket/aws"
309-
version = "~> 4.0"
309+
version = "~> 5.0"
310310

311311
bucket_prefix = "logs-1-"
312312
force_destroy = true
@@ -328,7 +328,7 @@ module "log_bucket_1" {
328328

329329
module "log_bucket_2" {
330330
source = "terraform-aws-modules/s3-bucket/aws"
331-
version = "~> 4.0"
331+
version = "~> 5.0"
332332

333333
bucket_prefix = "logs-2-"
334334
force_destroy = true

examples/complete/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.3"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.0"
7+
version = ">= 6.0"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/simple/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ Note that this example may create resources which will incur monetary charges on
1919

2020
| Name | Version |
2121
|------|---------|
22-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers
2727

2828
| Name | Version |
2929
|------|---------|
30-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
3131
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
3232

3333
## Modules

examples/simple/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.3"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.0"
7+
version = ">= 6.0"
88
}
99
random = {
1010
source = "hashicorp/random"

modules/log_forwarder/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ module "datadog_log_forwarder" {
4141

4242
| Name | Version |
4343
|------|---------|
44-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
45-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
44+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
45+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
4646
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
4747

4848
## Providers
4949

5050
| Name | Version |
5151
|------|---------|
52-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |
52+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
5353
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.0 |
5454

5555
## Modules
5656

5757
| Name | Source | Version |
5858
|------|--------|---------|
59-
| <a name="module_this_s3_bucket"></a> [this\_s3\_bucket](#module\_this\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | v3.6.1 |
59+
| <a name="module_this_s3_bucket"></a> [this\_s3\_bucket](#module\_this\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | v5.2.0 |
6060

6161
## Resources
6262

@@ -79,7 +79,7 @@ module "datadog_log_forwarder" {
7979

8080
| Name | Description | Type | Default | Required |
8181
|------|-------------|------|---------|:--------:|
82-
| <a name="input_architectures"></a> [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are `["x86_64"]` and `["arm64"]`. Default is `["x86_64"]` | `list(string)` | <pre>[<br/> "x86_64"<br/>]</pre> | no |
82+
| <a name="input_architectures"></a> [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are `["x86_64"]` and `["arm64"]`. Default is `["arm64"]` | `list(string)` | <pre>[<br/> "arm64"<br/>]</pre> | no |
8383
| <a name="input_bucket_attach_deny_insecure_transport_policy"></a> [bucket\_attach\_deny\_insecure\_transport\_policy](#input\_bucket\_attach\_deny\_insecure\_transport\_policy) | Controls if S3 bucket should have deny non-SSL transport policy attacheds | `bool` | `false` | no |
8484
| <a name="input_bucket_encryption_settings"></a> [bucket\_encryption\_settings](#input\_bucket\_encryption\_settings) | S3 bucket server side encryption settings | `map(string)` | <pre>{<br/> "sse_algorithm": "AES256"<br/>}</pre> | no |
8585
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Forwarder S3 bucket name | `string` | `""` | no |
@@ -93,7 +93,7 @@ module "datadog_log_forwarder" {
9393
| <a name="input_dd_api_key_secret_arn"></a> [dd\_api\_key\_secret\_arn](#input\_dd\_api\_key\_secret\_arn) | The ARN of the Secrets Manager secret storing the Datadog API key, if you already have it stored in Secrets Manager | `string` | `""` | no |
9494
| <a name="input_dd_site"></a> [dd\_site](#input\_dd\_site) | Define your Datadog Site to send data to. For the Datadog EU site, set to datadoghq.eu | `string` | `"datadoghq.com"` | no |
9595
| <a name="input_environment_variables"></a> [environment\_variables](#input\_environment\_variables) | A map of environment variables for the forwarder lambda function | `map(string)` | `{}` | no |
96-
| <a name="input_forwarder_version"></a> [forwarder\_version](#input\_forwarder\_version) | Forwarder version - see https://github.com/DataDog/datadog-serverless-functions/releases | `string` | `"3.130.0"` | no |
96+
| <a name="input_forwarder_version"></a> [forwarder\_version](#input\_forwarder\_version) | Forwarder version - see https://github.com/DataDog/datadog-serverless-functions/releases | `string` | `"4.12.0"` | no |
9797
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | KMS key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key | `string` | `null` | no |
9898
| <a name="input_lambda_tags"></a> [lambda\_tags](#input\_lambda\_tags) | A map of tags to apply to the forwarder lambda function | `map(string)` | `{}` | no |
9999
| <a name="input_layers"></a> [layers](#input\_layers) | List of Lambda Layer Version ARNs (maximum of 5) to attach to the forwarder lambda | `list(string)` | `[]` | no |
@@ -112,7 +112,7 @@ module "datadog_log_forwarder" {
112112
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | Forwarder role path | `string` | `null` | no |
113113
| <a name="input_role_permissions_boundary"></a> [role\_permissions\_boundary](#input\_role\_permissions\_boundary) | The ARN of the policy that is used to set the permissions boundary for the forwarder role | `string` | `null` | no |
114114
| <a name="input_role_tags"></a> [role\_tags](#input\_role\_tags) | A map of tags to apply to the forwarder role | `map(string)` | `{}` | no |
115-
| <a name="input_runtime"></a> [runtime](#input\_runtime) | Lambda function runtime | `string` | `"python3.11"` | no |
115+
| <a name="input_runtime"></a> [runtime](#input\_runtime) | Lambda function runtime | `string` | `"python3.12"` | no |
116116
| <a name="input_s3_log_bucket_arns"></a> [s3\_log\_bucket\_arns](#input\_s3\_log\_bucket\_arns) | S3 log buckets for forwarder to read and forward logs to Datadog | `list(string)` | `[]` | no |
117117
| <a name="input_s3_zip_kms_key_id"></a> [s3\_zip\_kms\_key\_id](#input\_s3\_zip\_kms\_key\_id) | The AWS KMS Key ARN to use for object encryption | `string` | `null` | no |
118118
| <a name="input_s3_zip_metadata"></a> [s3\_zip\_metadata](#input\_s3\_zip\_metadata) | A map of keys/values to provision metadata (will be automatically prefixed by `x-amz-meta-` | `map(string)` | `{}` | no |

modules/log_forwarder/main.tf

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
bucket_name = var.bucket_name != "" ? var.bucket_name : "datadog-forwarder-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"
2+
bucket_name = var.bucket_name != "" ? var.bucket_name : "datadog-forwarder-${data.aws_caller_identity.current[0].account_id}-${data.aws_region.current[0].region}"
33

44
dd_api_key = var.dd_api_key != "" ? { DD_API_KEY = var.dd_api_key } : {}
55
dd_api_key_secret_arn = var.dd_api_key_secret_arn != "" ? { DD_API_KEY_SECRET_ARN = var.dd_api_key_secret_arn } : {}
@@ -15,16 +15,20 @@ locals {
1515
forwarder_zip = "${path.module}/${local.zip_name}"
1616
}
1717

18-
data "aws_caller_identity" "current" {}
19-
data "aws_region" "current" {}
18+
data "aws_caller_identity" "current" {
19+
count = var.create ? 1 : 0
20+
}
21+
data "aws_region" "current" {
22+
count = var.create ? 1 : 0
23+
}
2024

2125
################################################################################
2226
# Forwarder Bucket
2327
################################################################################
2428

2529
module "this_s3_bucket" {
2630
source = "terraform-aws-modules/s3-bucket/aws"
27-
version = "v3.6.1"
31+
version = "v5.2.0"
2832

2933
create_bucket = var.create && var.create_bucket
3034
bucket = local.bucket_name
@@ -54,7 +58,13 @@ module "this_s3_bucket" {
5458
# Forwarder IAM Role
5559
################################################################################
5660

61+
locals {
62+
create_role = var.create && var.create_role
63+
}
64+
5765
data "aws_iam_policy_document" "this" {
66+
count = local.create_role ? 1 : 0
67+
5868
statement {
5969
actions = [
6070
"sts:AssumeRole",
@@ -68,14 +78,14 @@ data "aws_iam_policy_document" "this" {
6878
}
6979

7080
resource "aws_iam_role" "this" {
71-
count = var.create && var.create_role ? 1 : 0
81+
count = local.create_role ? 1 : 0
7282

7383
name = var.use_role_name_prefix ? null : local.role_name
7484
name_prefix = var.use_role_name_prefix ? "${local.role_name}-" : null
7585
description = local.description
7686
path = var.role_path
7787

78-
assume_role_policy = data.aws_iam_policy_document.this.json
88+
assume_role_policy = data.aws_iam_policy_document.this[0].json
7989
max_session_duration = var.role_max_session_duration
8090
permissions_boundary = var.role_permissions_boundary
8191
force_detach_policies = true
@@ -84,7 +94,7 @@ resource "aws_iam_role" "this" {
8494
}
8595

8696
resource "aws_iam_policy" "this" {
87-
count = var.create && var.create_role_policy ? 1 : 0
97+
count = local.create_role && var.create_role_policy ? 1 : 0
8898

8999
name = var.use_policy_name_prefix ? null : local.policy_name
90100
name_prefix = var.use_policy_name_prefix ? "${local.policy_name}-" : null
@@ -106,7 +116,7 @@ resource "aws_iam_policy" "this" {
106116
}
107117

108118
resource "aws_iam_role_policy_attachment" "this" {
109-
count = var.create && var.create_role ? 1 : 0
119+
count = local.create_role ? 1 : 0
110120

111121
role = aws_iam_role.this[0].id
112122
policy_arn = var.create_role_policy ? aws_iam_policy.this[0].id : var.policy_arn
@@ -205,8 +215,8 @@ resource "aws_lambda_permission" "cloudwatch" {
205215
statement_id = "datadog-forwarder-CloudWatchLogsPermission"
206216
action = "lambda:InvokeFunction"
207217
function_name = aws_lambda_function.this[0].function_name
208-
principal = "logs.${data.aws_region.current.name}.amazonaws.com"
209-
source_account = data.aws_caller_identity.current.account_id
218+
principal = "logs.${data.aws_region.current[0].region}.amazonaws.com"
219+
source_account = data.aws_caller_identity.current[0].account_id
210220
}
211221

212222
resource "aws_lambda_permission" "s3" {
@@ -216,7 +226,7 @@ resource "aws_lambda_permission" "s3" {
216226
action = "lambda:InvokeFunction"
217227
function_name = aws_lambda_function.this[0].function_name
218228
principal = "s3.amazonaws.com"
219-
source_account = data.aws_caller_identity.current.account_id
229+
source_account = data.aws_caller_identity.current[0].account_id
220230
}
221231

222232
resource "aws_cloudwatch_log_group" "this" {

modules/log_forwarder/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ variable "s3_log_bucket_arns" {
194194
variable "forwarder_version" {
195195
description = "Forwarder version - see https://github.com/DataDog/datadog-serverless-functions/releases"
196196
type = string
197-
default = "3.130.0"
197+
default = "4.12.0"
198198
}
199199

200200
variable "name" {
@@ -206,7 +206,7 @@ variable "name" {
206206
variable "runtime" {
207207
description = "Lambda function runtime"
208208
type = string
209-
default = "python3.11"
209+
default = "python3.12"
210210
}
211211

212212
variable "layers" {
@@ -234,9 +234,9 @@ variable "publish" {
234234
}
235235

236236
variable "architectures" {
237-
description = "Instruction set architecture for your Lambda function. Valid values are `[\"x86_64\"]` and `[\"arm64\"]`. Default is `[\"x86_64\"]`"
237+
description = "Instruction set architecture for your Lambda function. Valid values are `[\"x86_64\"]` and `[\"arm64\"]`. Default is `[\"arm64\"]`"
238238
type = list(string)
239-
default = ["x86_64"]
239+
default = ["arm64"]
240240
}
241241

242242
variable "reserved_concurrent_executions" {

0 commit comments

Comments
 (0)