Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(examples): Updating Terraform example to match the blog post #2347

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions examples/tracetest-aws-terraform-serverless/api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,6 @@ resource "aws_iam_policy" "lambda_network_policy" {
EOF
}


module "lambda_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = "${local.name}_lambda_security_group"
description = "Lambda security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access from anywhere"
cidr_blocks = "0.0.0.0/0"
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}

resource "aws_apigatewayv2_api" "lambda" {
name = "${local.name}_lambda_gw"
protocol_type = "HTTP"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.55.0"
}
tls = {
source = "hashicorp/tls"
version = "4.0.4"
}
}
}

provider "aws" {
region = local.region
}

data "aws_caller_identity" "current" {}
data "aws_availability_zones" "available" {}

resource "aws_ecs_cluster" "tracetest-cluster" {
name = "tracetest"
tags = local.tags
}

module "tracetest_ecs_service_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = "tracetest_ecs_service_security_group"
description = "ECS Service security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "tcp"
description = "HTTP access from VPC"
cidr_blocks = local.vpc_cidr
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}

resource "aws_iam_role" "tracetest_task_execution_role" {
name = "tracetest_task_execution_role"

Expand Down
54 changes: 54 additions & 0 deletions examples/tracetest-aws-terraform-serverless/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,57 @@ resource "aws_lb" "internal_tracetest_alb" {
enable_deletion_protection = false
tags = local.tags
}

module "lambda_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = "${local.name}_lambda_security_group"
description = "Lambda security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access from anywhere"
cidr_blocks = "0.0.0.0/0"
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}

module "tracetest_ecs_service_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = "tracetest_ecs_service_security_group"
description = "ECS Service security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "tcp"
description = "HTTP access from VPC"
cidr_blocks = local.vpc_cidr
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ spec:
trigger:
type: http
httpRequest:
url: <your_api_endpoint>
url: https://3x6vvt7l5d.execute-api.us-west-2.amazonaws.com/dev/hello
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this URL be public?

method: GET
headers:
- key: Content-Type
Expand Down
20 changes: 20 additions & 0 deletions examples/tracetest-aws-terraform-serverless/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.55.0"
}
tls = {
source = "hashicorp/tls"
version = "4.0.4"
}
}
}

provider "aws" {
region = local.region
}

data "aws_caller_identity" "current" {}
data "aws_availability_zones" "available" {}

variable "aws_region" {
type = string
default = "us-west-2"
Expand Down