Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 54e0d21

Browse files
authored
Terraform Provider v5 Support (#48)
* tf provider v5 changes, make readme, updated example * make commands * tflint brackets for lists * reset .github dir * reset lambda and codeowner workflows * added versions.tf to example * updated versions * corrected inputs for tests * handle external git * extend terratest * make readme * update correct Makefile * remove duplicated strings for test assertions * remove duplicated strings for test assertions
1 parent 700e1dc commit 54e0d21

File tree

10 files changed

+1057
-73
lines changed

10 files changed

+1057
-73
lines changed

‎README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ We highly recommend that in your code you pin the version to the exact version y
9494
using so that your infrastructure remains stable, and update versions in a
9595
systematic way so that they do not catch you by surprise.
9696

97-
Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
98-
the registry shows many of our inputs as required when in fact they are optional.
99-
The table below correctly indicates which inputs are required.
100-
10197

10298

10399
For a complete example, see [examples/complete](examples/complete).
@@ -179,21 +175,21 @@ is given
179175

180176
| Name | Version |
181177
|------|---------|
182-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
183-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
184-
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
178+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
179+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
180+
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
185181

186182
## Providers
187183

188184
| Name | Version |
189185
|------|---------|
190-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.0 |
186+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0 |
191187

192188
## Modules
193189

194190
| Name | Source | Version |
195191
|------|--------|---------|
196-
| <a name="module_artifact"></a> [artifact](#module\_artifact) | cloudposse/module-artifact/external | 0.7.1 |
192+
| <a name="module_artifact"></a> [artifact](#module\_artifact) | cloudposse/module-artifact/external | 0.8.0 |
197193
| <a name="module_label"></a> [label](#module\_label) | cloudposse/label/null | 0.25.0 |
198194
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
199195

@@ -354,7 +350,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
354350

355351
## Copyright
356352

357-
Copyright © 2017-2022 [Cloud Posse, LLC](https://cpco.io/copyright)
353+
Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright)
358354

359355

360356

@@ -429,7 +425,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
429425

430426
[![README Footer][readme_footer_img]][readme_footer_link]
431427
[![Beacon][beacon]][website]
432-
428+
<!-- markdownlint-disable -->
433429
[logo]: https://cloudposse.com/logo-300x69.svg
434430
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-lambda-elasticsearch-cleanup&utm_content=docs
435431
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-lambda-elasticsearch-cleanup&utm_content=website
@@ -460,3 +456,4 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
460456
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup
461457
[share_email]: mailto:?subject=terraform-aws-lambda-elasticsearch-cleanup&body=https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup
462458
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-lambda-elasticsearch-cleanup?pixel&cs=github&cm=readme&an=terraform-aws-lambda-elasticsearch-cleanup
459+
<!-- markdownlint-restore -->

‎docs/terraform.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ is given
1010

1111
| Name | Version |
1212
|------|---------|
13-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
14-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.0 |
15-
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
13+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
14+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |
15+
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
1616

1717
## Providers
1818

1919
| Name | Version |
2020
|------|---------|
21-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.0 |
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0 |
2222

2323
## Modules
2424

2525
| Name | Source | Version |
2626
|------|--------|---------|
27-
| <a name="module_artifact"></a> [artifact](#module\_artifact) | cloudposse/module-artifact/external | 0.7.1 |
27+
| <a name="module_artifact"></a> [artifact](#module\_artifact) | cloudposse/module-artifact/external | 0.8.0 |
2828
| <a name="module_label"></a> [label](#module\_label) | cloudposse/label/null | 0.25.0 |
2929
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
3030

‎examples/complete/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ provider "aws" {
44

55
module "vpc" {
66
source = "cloudposse/vpc/aws"
7-
version = "0.17.0"
7+
version = "2.1.0"
88

9-
cidr_block = "172.16.0.0/16"
9+
ipv4_primary_cidr_block = "172.16.0.0/16"
1010

1111
context = module.this.context
1212
}
1313

1414
module "subnets" {
1515
source = "cloudposse/dynamic-subnets/aws"
16-
version = "0.30.0"
16+
version = "2.4.1"
1717

1818
availability_zones = var.availability_zones
1919
vpc_id = module.vpc.vpc_id
20-
igw_id = module.vpc.igw_id
21-
cidr_block =module.vpc.vpc_cidr_block
20+
igw_id = [module.vpc.igw_id]
21+
ipv4_cidr_block =[module.vpc.vpc_cidr_block]
2222
nat_gateway_enabled = true
2323
nat_instance_enabled = false
2424

@@ -27,7 +27,7 @@ module "subnets" {
2727

2828
module "elasticsearch" {
2929
source = "cloudposse/elasticsearch/aws"
30-
version = "0.24.0"
30+
version = "0.44.0"
3131

3232
security_groups = [module.vpc.vpc_default_security_group_id]
3333
vpc_id = module.vpc.vpc_id

‎examples/complete/versions.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.0.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 3.0"
8+
}
9+
null = {
10+
source = "hashicorp/null"
11+
version = ">= 3.0"
12+
}
13+
}
14+
}

‎main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ data "aws_iam_policy_document" "sns" {
7676
data "aws_iam_policy_document" "default" {
7777
count = local.enabled ? 1 : 0
7878

79-
source_json = join("", data.aws_iam_policy_document.es_logs.*.json)
80-
override_json = length(var.sns_arn) > 0 ? join("", data.aws_iam_policy_document.sns.*.json) : "{}"
79+
source_policy_documents = [join("", data.aws_iam_policy_document.es_logs[*].json)]
80+
override_policy_documents = length(var.sns_arn) > 0 ? [join("", data.aws_iam_policy_document.sns[*].json)] : ["{}"]
8181
}
8282

8383
locals {
@@ -98,7 +98,7 @@ module "label" {
9898

9999
module "artifact" {
100100
source = "cloudposse/module-artifact/external"
101-
version = "0.7.1"
101+
version = "0.8.0"
102102
enabled = module.this.enabled
103103
filename = "lambda.zip"
104104
module_name = "terraform-aws-lambda-elasticsearch-cleanup"
@@ -122,7 +122,7 @@ resource "aws_lambda_function" "default" {
122122
description = local.function_name
123123
timeout = var.timeout
124124
runtime = "python${var.python_version}"
125-
role = join("", aws_iam_role.default.*.arn)
125+
role = join("", aws_iam_role.default[*].arn)
126126
handler = "es-cleanup.lambda_handler"
127127
source_code_hash = module.artifact.base64sha256
128128
tags = module.label.tags
@@ -140,7 +140,7 @@ resource "aws_lambda_function" "default" {
140140

141141
vpc_config {
142142
subnet_ids = var.subnet_ids
143-
security_group_ids = [join("", aws_security_group.default.*.id)]
143+
security_group_ids = [join("", aws_security_group.default[*].id)]
144144
}
145145
}
146146

@@ -160,7 +160,7 @@ resource "aws_security_group_rule" "udp_dns_egress_from_lambda" {
160160
to_port = 53
161161
protocol = "udp"
162162
cidr_blocks = ["0.0.0.0/0"]
163-
security_group_id = join("", aws_security_group.default.*.id)
163+
security_group_id = join("", aws_security_group.default[*].id)
164164
}
165165

166166
resource "aws_security_group_rule" "tcp_dns_egress_from_lambda" {
@@ -171,7 +171,7 @@ resource "aws_security_group_rule" "tcp_dns_egress_from_lambda" {
171171
to_port = 53
172172
protocol = "tcp"
173173
cidr_blocks = ["0.0.0.0/0"]
174-
security_group_id = join("", aws_security_group.default.*.id)
174+
security_group_id = join("", aws_security_group.default[*].id)
175175
}
176176

177177
resource "aws_security_group_rule" "egress_from_lambda_to_es_cluster" {
@@ -182,7 +182,7 @@ resource "aws_security_group_rule" "egress_from_lambda_to_es_cluster" {
182182
to_port = 443
183183
protocol = "tcp"
184184
source_security_group_id = var.es_security_group_id
185-
security_group_id = join("", aws_security_group.default.*.id)
185+
security_group_id = join("", aws_security_group.default[*].id)
186186
}
187187

188188
resource "aws_security_group_rule" "ingress_to_es_cluster_from_lambda" {
@@ -192,27 +192,27 @@ resource "aws_security_group_rule" "ingress_to_es_cluster_from_lambda" {
192192
from_port = 443
193193
to_port = 443
194194
protocol = "tcp"
195-
source_security_group_id = join("", aws_security_group.default.*.id)
195+
source_security_group_id = join("", aws_security_group.default[*].id)
196196
security_group_id = var.es_security_group_id
197197
}
198198

199199
resource "aws_iam_role" "default" {
200200
count = local.enabled ? 1 : 0
201201
name = local.function_name
202-
assume_role_policy = join("", data.aws_iam_policy_document.assume_role.*.json)
202+
assume_role_policy = join("", data.aws_iam_policy_document.assume_role[*].json)
203203
tags = module.label.tags
204204
}
205205

206206
resource "aws_iam_role_policy" "default" {
207207
count = local.enabled ? 1 : 0
208208
name = local.function_name
209-
role = join("", aws_iam_role.default.*.name)
210-
policy = join("", data.aws_iam_policy_document.default.*.json)
209+
role = join("", aws_iam_role.default[*].name)
210+
policy = join("", data.aws_iam_policy_document.default[*].json)
211211
}
212212

213213
resource "aws_iam_role_policy_attachment" "default" {
214214
count = local.enabled ? 1 : 0
215-
role = join("", aws_iam_role.default.*.name)
215+
role = join("", aws_iam_role.default[*].name)
216216
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
217217
}
218218

@@ -227,14 +227,14 @@ resource "aws_lambda_permission" "default" {
227227
count = local.enabled ? 1 : 0
228228
statement_id = "AllowExecutionFromCloudWatch"
229229
action = "lambda:InvokeFunction"
230-
function_name = join("", aws_lambda_function.default.*.arn)
230+
function_name = join("", aws_lambda_function.default[*].arn)
231231
principal = "events.amazonaws.com"
232-
source_arn = join("", aws_cloudwatch_event_rule.default.*.arn)
232+
source_arn = join("", aws_cloudwatch_event_rule.default[*].arn)
233233
}
234234

235235
resource "aws_cloudwatch_event_target" "default" {
236236
count = local.enabled ? 1 : 0
237237
target_id = local.function_name
238-
rule = join("", aws_cloudwatch_event_rule.default.*.name)
239-
arn = join("", aws_lambda_function.default.*.arn)
238+
rule = join("", aws_cloudwatch_event_rule.default[*].name)
239+
arn = join("", aws_lambda_function.default[*].arn)
240240
}

‎outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
output "security_group_id" {
2-
value = join("", aws_security_group.default.*.id)
2+
value = join("", aws_security_group.default[*].id)
33
description = "Security Group ID of the Lambda Function"
44
}
55

66
output "lambda_function_arn" {
7-
value = join("", aws_lambda_function.default.*.arn)
7+
value = join("", aws_lambda_function.default[*].arn)
88
description = "ARN of the Lambda Function"
99
}
1010

1111
output "lambda_function_source_code_size" {
12-
value = join("", aws_lambda_function.default.*.source_code_size)
12+
value = join("", aws_lambda_function.default[*].source_code_size)
1313
description = "The size in bytes of the function .zip file"
1414
}

‎test/src/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ init:
1515
.PHONY : test
1616
## Run tests
1717
test: init
18+
# This project runs `git` externally, so it needs extra permissions when run by a GitHub Action
19+
[[ -n "$$GITHUB_WORKSPACE" ]] && git config --global --add safe.directory "$$GITHUB_WORKSPACE" || true
1820
go mod download
1921
go test -v -timeout 60m -run TestExamplesComplete
2022

‎test/src/go.mod

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
module github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup
22

3-
go 1.14
3+
go 1.20
44

55
require (
6-
github.com/aws/aws-sdk-go v1.35.4 // indirect
6+
github.com/gruntwork-io/terratest v0.43.8
7+
github.com/stretchr/testify v1.8.4
8+
)
9+
10+
require (
11+
cloud.google.com/go v0.105.0 // indirect
12+
cloud.google.com/go/compute v1.12.1 // indirect
13+
cloud.google.com/go/compute/metadata v0.2.1 // indirect
14+
cloud.google.com/go/iam v0.7.0 // indirect
15+
cloud.google.com/go/storage v1.27.0 // indirect
16+
github.com/agext/levenshtein v1.2.3 // indirect
17+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
18+
github.com/aws/aws-sdk-go v1.44.122 // indirect
19+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
720
github.com/davecgh/go-spew v1.1.1 // indirect
8-
github.com/google/uuid v1.1.2 // indirect
9-
github.com/gruntwork-io/terratest v0.16.0
10-
github.com/pquerna/otp v1.2.0 // indirect
11-
github.com/stretchr/testify v1.3.0
12-
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
13-
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect
21+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
22+
github.com/golang/protobuf v1.5.3 // indirect
23+
github.com/google/go-cmp v0.5.9 // indirect
24+
github.com/google/uuid v1.3.0 // indirect
25+
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
26+
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
27+
github.com/hashicorp/errwrap v1.0.0 // indirect
28+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
29+
github.com/hashicorp/go-getter v1.7.1 // indirect
30+
github.com/hashicorp/go-multierror v1.1.0 // indirect
31+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
32+
github.com/hashicorp/go-version v1.6.0 // indirect
33+
github.com/hashicorp/hcl/v2 v2.9.1 // indirect
34+
github.com/hashicorp/terraform-json v0.13.0 // indirect
35+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
36+
github.com/jmespath/go-jmespath v0.4.0 // indirect
37+
github.com/klauspost/compress v1.15.11 // indirect
38+
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
39+
github.com/mitchellh/go-homedir v1.1.0 // indirect
40+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
41+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
42+
github.com/pmezard/go-difflib v1.0.0 // indirect
43+
github.com/tmccombs/hcl2json v0.3.3 // indirect
44+
github.com/ulikunitz/xz v0.5.10 // indirect
45+
github.com/zclconf/go-cty v1.9.1 // indirect
46+
go.opencensus.io v0.24.0 // indirect
47+
golang.org/x/crypto v0.1.0 // indirect
48+
golang.org/x/net v0.8.0 // indirect
49+
golang.org/x/oauth2 v0.1.0 // indirect
50+
golang.org/x/sys v0.6.0 // indirect
51+
golang.org/x/text v0.8.0 // indirect
52+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
53+
google.golang.org/api v0.103.0 // indirect
54+
google.golang.org/appengine v1.6.7 // indirect
55+
google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c // indirect
56+
google.golang.org/grpc v1.51.0 // indirect
57+
google.golang.org/protobuf v1.31.0 // indirect
58+
gopkg.in/yaml.v3 v3.0.1 // indirect
1459
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /