-
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
test: adding integration testing to test supporting terraform nested directories project structure #5748
Merged
moelasmar
merged 5 commits into
aws:develop
from
moelasmar:develop_nested_directories_integration_testing
Aug 11, 2023
Merged
test: adding integration testing to test supporting terraform nested directories project structure #5748
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4cf29a
feat: support terraform project structure that does not have everythi…
moelasmar 12d63c6
test: adding integration testing to test supporting terraform nested …
moelasmar 3574b0b
Merge remote-tracking branch 'aws-sam-cli/develop' into develop_root_…
moelasmar 5d02743
Merge branch 'develop' into develop_nested_directories_integration_te…
moelasmar 0e5e5d6
fix the terraform config, remove the aws provider configuration.
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
42 changes: 42 additions & 0 deletions
42
...ata/buildcmd/terraform/application_outside_root_directory/modules/lambda_function/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,42 @@ | ||
variable "source_code" { | ||
type = string | ||
} | ||
|
||
variable "function_name" { | ||
type = string | ||
} | ||
|
||
variable "layers" { | ||
type = list | ||
default = [] | ||
} | ||
|
||
resource "aws_iam_role" "iam_for_lambda" { | ||
name = "iam_for_lambda2" | ||
|
||
assume_role_policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
}, | ||
"Effect": "Allow", | ||
"Sid": "" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
|
||
resource "aws_lambda_function" "this" { | ||
filename = var.source_code | ||
handler = "app.lambda_handler" | ||
runtime = "python3.8" | ||
function_name = var.function_name | ||
role = aws_iam_role.iam_for_lambda.arn | ||
layers = var.layers | ||
timeout = 300 | ||
} |
18 changes: 18 additions & 0 deletions
18
...stdata/buildcmd/terraform/application_outside_root_directory/modules/lambda_layer/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,18 @@ | ||
variable "source_code" { | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
type = string | ||
} | ||
|
||
resource "aws_lambda_layer_version" "layer" { | ||
filename = var.source_code | ||
layer_name = var.name | ||
|
||
compatible_runtimes = ["python3.8"] | ||
} | ||
|
||
output "arn" { | ||
value = aws_lambda_layer_version.layer.arn | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/integration/testdata/buildcmd/terraform/application_outside_root_directory/py_build.sh
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,28 @@ | ||
#!/bin/bash | ||
src_code=$1 | ||
build_path=$2 | ||
output_name=$3 | ||
resource_type=$4 | ||
echo "building ${resource_type} ${src_code} into ${build_path}" | ||
|
||
temp_path=${build_path}/tmp_building/${output_name} | ||
if [[ "${resource_type}" == "Layer" ]]; then | ||
temp_path=${build_path}/tmp_building/${output_name}/python | ||
echo "new path ${temp_path}" | ||
fi | ||
|
||
mkdir -p ${build_path} | ||
mkdir -p ${build_path}/tmp_building | ||
mkdir -p ${build_path}/tmp_building/${output_name} | ||
mkdir -p ${temp_path} | ||
rm -rf ${temp_path}/* | ||
|
||
cp -r $src_code/* ${temp_path} | ||
pip install -r ${temp_path}/requirements.txt -t ${temp_path}/. | ||
current=$(pwd) | ||
cd ${build_path}/tmp_building/${output_name} | ||
zip -r ${output_name} . | ||
cd ${current} | ||
mv "${build_path}/tmp_building/${output_name}/${output_name}" "${build_path}/$output_name" | ||
rm -rf ${build_path}/tmp_building/${output_name} | ||
rm -rf ${build_path}/tmp_building |
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.
Is the plan to add more functions? Just poking at this since they all have the same output
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.
I am testing lambda functions/layers defined in different ways - in the root module - in external modules - using 3rd party modules, and all of them are referring to the same source code, so the output is the same for all of them
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.
and source code, and custom modules are defined in a different directory structure outside the root module directory