From d97b51ce4df8290250327d92c6321ca04b753a4a Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 11 Feb 2025 11:46:08 +0100 Subject: [PATCH] Add example of VPC config. --- examples/provisioned_concurrency/versions.tf | 2 +- examples/sqs/versions.tf | 2 +- examples/vpc/main.tf | 35 ++++++++++++++++++++ examples/vpc/versions.tf | 12 +++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 examples/vpc/main.tf create mode 100644 examples/vpc/versions.tf diff --git a/examples/provisioned_concurrency/versions.tf b/examples/provisioned_concurrency/versions.tf index 890d20b..7dbcdc5 100644 --- a/examples/provisioned_concurrency/versions.tf +++ b/examples/provisioned_concurrency/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { vy = { source = "nsbno/vy" - version = "0.3.1" + version = "0.4.0" } } } diff --git a/examples/sqs/versions.tf b/examples/sqs/versions.tf index 890d20b..7dbcdc5 100644 --- a/examples/sqs/versions.tf +++ b/examples/sqs/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { vy = { source = "nsbno/vy" - version = "0.3.1" + version = "0.4.0" } } } diff --git a/examples/vpc/main.tf b/examples/vpc/main.tf new file mode 100644 index 0000000..b059689 --- /dev/null +++ b/examples/vpc/main.tf @@ -0,0 +1,35 @@ +data "vy_artifact_version" "this" { + application = "user-service" +} + +module "account_metadata" { + source = "github.com/nsbno/terraform-aws-account-metadata?ref=0.3.1" +} + +module "lambda" { + source = "../../" + + name = "get-users" + + artifact_type = "s3" + artifact = data.vy_artifact_version.this + + runtime = "python3.11" + handler = "handler.main" + + subnet_ids = module.account_metadata.network.private_subnet_ids + security_group_ids = [aws_security_group.lambda_security_group.id] +} + +resource "aws_security_group" "lambda_security_group" { + name = "user-service-sg" + description = "Security group for Lambda function user-service" + vpc_id = module.account_metadata.network.vpc_id + + egress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} diff --git a/examples/vpc/versions.tf b/examples/vpc/versions.tf new file mode 100644 index 0000000..7dbcdc5 --- /dev/null +++ b/examples/vpc/versions.tf @@ -0,0 +1,12 @@ +terraform { + required_providers { + vy = { + source = "nsbno/vy" + version = "0.4.0" + } + } +} + +provider "vy" { + environment = "test" +}