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

test: Add Terraform V2 API Integration Test Cases #5634

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,20 @@ def tearDownClass(cls) -> None:
"Skip Terraform test cases unless running in CI",
)
@pytest.mark.flaky(reruns=3)
@parameterized_class(
[
{
"terraform_application": "terraform-v1-api-simple",
},
{
"terraform_application": "terraform-v2-api-simple",
},
{
"terraform_application": "terraform-v2-api-quick-create",
},
]
)
class TestStartApiTerraformApplication(TerraformStartApiIntegrationBase):
terraform_application = "terraform-v1-api-simple"

def setUp(self):
self.url = "http://127.0.0.1:{}".format(self.port)

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
provider "aws" {
}

resource "aws_iam_role" "iam_for_lambda" {
name = "iam_for_lambda"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

resource "aws_s3_bucket" "lambda_code_bucket" {
bucket = "lambda_code_bucket"
}

resource "aws_s3_object" "s3_lambda_code" {
bucket = "lambda_code_bucket"
key = "s3_lambda_code_key"
source = "HelloWorldFunction.zip"
}

resource "aws_lambda_function" "HelloWorldFunction" {
s3_bucket = "lambda_code_bucket"
s3_key = "s3_lambda_code_key"
handler = "app.lambda_handler"
runtime = "python3.8"
function_name = "HelloWorldFunction"
timeout = 500
role = aws_iam_role.iam_for_lambda.arn
}

resource "aws_apigatewayv2_api" "quick_create_api" {
name = "quick_create_api"
protocol_type = "HTTP"
target = aws_lambda_function.HelloWorldFunction.invoke_arn
route_key = "GET /hello"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
provider "aws" {
}

resource "aws_iam_role" "iam_for_lambda" {
name = "iam_for_lambda"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

resource "aws_s3_bucket" "lambda_code_bucket" {
bucket = "lambda_code_bucket"
}

resource "aws_s3_object" "s3_lambda_code" {
bucket = "lambda_code_bucket"
key = "s3_lambda_code_key"
source = "HelloWorldFunction.zip"
}

resource "aws_lambda_function" "HelloWorldFunction" {
s3_bucket = "lambda_code_bucket"
s3_key = "s3_lambda_code_key"
handler = "app.lambda_handler"
runtime = "python3.8"
function_name = "HelloWorldFunction"
timeout = 500
role = aws_iam_role.iam_for_lambda.arn
}

resource "aws_apigatewayv2_api" "my_api" {
name = "my_api"
protocol_type = "HTTP"
}

resource "aws_apigatewayv2_route" "example" {
api_id = aws_apigatewayv2_api.my_api.id
target = aws_apigatewayv2_integration.example.id
route_key = "GET /hello"
operation_name = "my_operation"
}

resource "aws_apigatewayv2_stage" "example" {
api_id = aws_apigatewayv2_api.my_api.id
name = "example-stage"
}

resource "aws_apigatewayv2_integration" "example" {
api_id = aws_apigatewayv2_api.my_api.id
integration_type = "AWS_PROXY"
integration_method = "POST"
integration_uri = aws_lambda_function.HelloWorldFunction.invoke_arn
payload_format_version = "2.0"
}
Loading