-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
tests: Added limitation test cases for V2 resources #5708
Merged
moelasmar
merged 11 commits into
aws:feat/terraform-v2-api
from
lucashuy:test_v2_limitations
Aug 5, 2023
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4e0ab08
Merge remote-tracking branch 'aws-sam-cli/develop' into feat/terrafor…
moelasmar 40aa32d
chore: merge from develop branch, and apply the linking refactor
moelasmar c4ea4a7
Added limitation test cases for V2 resources
lucashuy 34887eb
Removed commented out code
lucashuy 2d02421
fix merge mistake in the integration test cases
moelasmar ea2322c
Updated and added happy paths to apply test class
lucashuy c21f6ef
Use correct method for AWS_PROXY
lucashuy 029798d
Merge branch 'feat/terraform-v2-api-apply-linking-refactor' into test…
moelasmar 40b5c85
fix failing integration testing
moelasmar 42b4f44
Merge remote-tracking branch 'aws-sam-cli/feat/terraform-v2-api' into…
moelasmar bfb8937
fix merge conflicts
moelasmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.05 KB
...ta/start_api/terraform/terraform-v2-api-simple-local-resource-link/HelloWorldFunction.zip
Binary file not shown.
80 changes: 80 additions & 0 deletions
80
...egration/testdata/start_api/terraform/terraform-v2-api-simple-local-resource-link/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
provider "aws" { | ||
} | ||
|
||
locals { | ||
api_function = aws_lambda_function.HelloWorldFunction.invoke_arn | ||
} | ||
|
||
resource "random_uuid" "unique_id" { | ||
keepers = { | ||
my_key = "my_key" | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "iam_for_lambda" { | ||
name = "iam_for_lambda_${random_uuid.unique_id.result}" | ||
|
||
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-${random_uuid.unique_id.result}" | ||
} | ||
|
||
resource "aws_s3_object" "s3_lambda_code" { | ||
bucket = "lambda-code-bucket-${random_uuid.unique_id.result}" | ||
key = "s3_lambda_code_key" | ||
source = "HelloWorldFunction.zip" | ||
depends_on = [aws_s3_bucket.lambda_code_bucket] | ||
} | ||
|
||
resource "aws_lambda_function" "HelloWorldFunction" { | ||
s3_bucket = "lambda-code-bucket-${random_uuid.unique_id.result}" | ||
s3_key = "s3_lambda_code_key" | ||
handler = "app.lambda_handler" | ||
runtime = "python3.8" | ||
function_name = "HelloWorldFunction_${random_uuid.unique_id.result}" | ||
timeout = 500 | ||
role = aws_iam_role.iam_for_lambda.arn | ||
depends_on = [aws_s3_bucket.lambda_code_bucket] | ||
} | ||
|
||
resource "aws_apigatewayv2_api" "my_api" { | ||
name = "my_api_${random_uuid.unique_id.result}" | ||
protocol_type = "HTTP" | ||
} | ||
|
||
resource "aws_apigatewayv2_route" "example" { | ||
api_id = aws_apigatewayv2_api.my_api.id | ||
target = "integrations/${aws_apigatewayv2_integration.example.id}" | ||
route_key = "GET /hello" | ||
operation_name = "my_operation" | ||
depends_on = [aws_apigatewayv2_integration.example] | ||
} | ||
|
||
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 = local.api_function | ||
payload_format_version = "2.0" | ||
} |
Binary file added
BIN
+1.05 KB
...ta/start_api/terraform/terraform-v2-api-simple-multi-resource-link/HelloWorldFunction.zip
Binary file not shown.
93 changes: 93 additions & 0 deletions
93
...egration/testdata/start_api/terraform/terraform-v2-api-simple-multi-resource-link/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
provider "aws" { | ||
} | ||
|
||
variable "stage" { | ||
type = string | ||
description = "stage" | ||
default = "beta" | ||
} | ||
|
||
resource "random_uuid" "unique_id" { | ||
keepers = { | ||
my_key = "my_key" | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "iam_for_lambda" { | ||
name = "iam_for_lambda_${random_uuid.unique_id.result}" | ||
|
||
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-${random_uuid.unique_id.result}" | ||
} | ||
|
||
resource "aws_s3_object" "s3_lambda_code" { | ||
bucket = "lambda-code-bucket-${random_uuid.unique_id.result}" | ||
key = "s3_lambda_code_key" | ||
source = "HelloWorldFunction.zip" | ||
depends_on = [aws_s3_bucket.lambda_code_bucket] | ||
} | ||
|
||
resource "aws_lambda_function" "HelloWorldFunction" { | ||
s3_bucket = "lambda-code-bucket-${random_uuid.unique_id.result}" | ||
s3_key = "s3_lambda_code_key" | ||
handler = "app.lambda_handler" | ||
runtime = "python3.8" | ||
function_name = "HelloWorldFunction_${random_uuid.unique_id.result}" | ||
timeout = 500 | ||
role = aws_iam_role.iam_for_lambda.arn | ||
depends_on = [aws_s3_object.s3_lambda_code] | ||
} | ||
|
||
resource "aws_lambda_function" "HelloWorldFunction2" { | ||
s3_bucket = "lambda-code-bucket-${random_uuid.unique_id.result}" | ||
s3_key = "s3_lambda_code_key" | ||
handler = "app.lambda_handler" | ||
runtime = "python3.8" | ||
function_name = "HelloWorldFunction2_${random_uuid.unique_id.result}" | ||
timeout = 500 | ||
role = aws_iam_role.iam_for_lambda.arn | ||
depends_on = [aws_s3_object.s3_lambda_code] | ||
} | ||
|
||
resource "aws_apigatewayv2_api" "my_api" { | ||
name = "my_api_${random_uuid.unique_id.result}" | ||
protocol_type = "HTTP" | ||
} | ||
|
||
resource "aws_apigatewayv2_route" "example" { | ||
api_id = aws_apigatewayv2_api.my_api.id | ||
target = "integrations/${aws_apigatewayv2_integration.example.id}" | ||
route_key = "GET /hello" | ||
operation_name = "my_operation" | ||
depends_on = [aws_apigatewayv2_integration.example] | ||
} | ||
|
||
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 = var.stage == "beta" ? aws_lambda_function.HelloWorldFunction.invoke_arn : aws_lambda_function.HelloWorldFunction2.invoke_arn | ||
payload_format_version = "2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.05 KB
tests/integration/testdata/start_api/terraform/terraform-v2-openapi/lambda-functions.zip
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for resource
"aws_apigatewayv2_route" "example"
.. I think thetarget
property value should be in format"integrations/${<integration id>}"
. If it is working using this format when we runterraform apply
, please add another example to use the previous format as explained in the doc