Skip to content

Commit 277cdb2

Browse files
authored
Merge pull request #2 from pbs/feature/adding_lambda_test
Adding Lambda Test
2 parents 51454a3 + a94783a commit 277cdb2

18 files changed

+463
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
target
44
CHANGELOG.md
55
*tfstate*
6+
*.zip

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Use this URL for the source of the module. See the usage examples below for more details.
88

99
```hcl
10-
github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=0.0.1
10+
github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=x.y.z
1111
```
1212

1313
### Alternative Installation Methods
@@ -26,7 +26,7 @@ Integrate this module like so:
2626

2727
```hcl
2828
module "elasticache-redis-standalone" {
29-
source = "github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=0.0.1"
29+
source = "github.com/pbs/terraform-aws-elasticache-redis-standalone-module?ref=x.y.z"
3030
3131
# Tagging Parameters
3232
organization = var.organization
@@ -42,7 +42,7 @@ module "elasticache-redis-standalone" {
4242

4343
If this repo is added as a subtree, then the version of the module should be close to the version shown here:
4444

45-
`0.0.1`
45+
`x.y.z`
4646

4747
Note, however that subtrees can be altered as desired within repositories.
4848

examples/lambda/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
backend.tf
2+
provider.tf

examples/lambda/.terraform.lock.hcl

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/lambda/main.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module "lambda" {
2+
source = "github.com/pbs/terraform-aws-lambda-module?ref=0.0.5"
3+
4+
handler = "index.handler"
5+
filename = "./artifacts/handler.zip"
6+
runtime = "python3.9"
7+
8+
architectures = ["arm64"]
9+
10+
add_vpc_config = true
11+
12+
environment_vars = {
13+
"REDIS_PRIMARY_ENDPOINT" = module.redis.primary_endpoint_address
14+
"REDIS_READER_ENDPOINT" = module.redis.reader_endpoint_address
15+
}
16+
17+
organization = var.organization
18+
environment = var.environment
19+
product = var.product
20+
repo = var.repo
21+
}
22+
23+
module "redis" {
24+
source = "../.."
25+
26+
organization = var.organization
27+
environment = var.environment
28+
product = var.product
29+
repo = var.repo
30+
}
31+
32+
resource "aws_security_group_rule" "redis_ingress_rule" {
33+
type = "ingress"
34+
from_port = 6379
35+
to_port = 6379
36+
protocol = "tcp"
37+
source_security_group_id = module.lambda.sg
38+
security_group_id = module.redis.sg_ids[0]
39+
}

examples/lambda/outputs.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
output "name" {
2+
description = "The name of the ElastiCache replication group"
3+
value = module.redis.name
4+
}
5+
6+
output "arn" {
7+
description = "The ARN of the ElastiCache replication group"
8+
value = module.redis.arn
9+
}
10+
11+
output "sg_ids" {
12+
description = "The security group ids"
13+
value = module.redis.sg_ids
14+
}
15+
16+
output "engine_version_actual" {
17+
description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine."
18+
value = module.redis.engine_version_actual
19+
}
20+
21+
output "member_clusters" {
22+
description = "Identifiers of all the nodes that are part of this replication group."
23+
value = module.redis.member_clusters
24+
}
25+
26+
output "primary_endpoint_address" {
27+
description = "Address of the endpoint for the primary node in the replication group."
28+
value = module.redis.primary_endpoint_address
29+
}
30+
31+
output "reader_endpoint_address" {
32+
description = "Address of the endpoint for the reader node in the replication group."
33+
value = module.redis.reader_endpoint_address
34+
}
35+
36+
output "tags" {
37+
description = "The tags"
38+
value = module.redis.tags
39+
}
40+
41+
output "lambda_name" {
42+
description = "The name of the lambda function"
43+
value = module.lambda.name
44+
}

examples/lambda/sample-backend.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# terraform {
2+
# backend "s3" {
3+
# bucket = "my-bucket-tfstate"
4+
# key = "example-terraform-aws-elasticache-redis-standalone-lambda"
5+
# profile = "my-profile"
6+
# region = "us-east-1"
7+
# dynamodb_table = "terraform-lock"
8+
# }
9+
# }

examples/lambda/sample-provider.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# provider "aws" {
2+
# region = "us-east-1"
3+
# profile = "my-profile"
4+
# default_tags {
5+
# tags = {
6+
# product = var.product
7+
# environment = var.environment
8+
# repo = var.repo
9+
# organization = var.organization
10+
# }
11+
# }
12+
# }

examples/lambda/src/Pipfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
redis = "*"
8+
hiredis = "*"
9+
10+
[dev-packages]
11+
12+
[requires]
13+
python_version = "3.10"

examples/lambda/src/Pipfile.lock

Lines changed: 178 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)