Skip to content

Commit ced88a7

Browse files
committed
Initial
0 parents  commit ced88a7

File tree

11 files changed

+179
-0
lines changed

11 files changed

+179
-0
lines changed

.github/workflows/terraform.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Terraform
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
12+
job1:
13+
name: Style
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Format
19+
run: terraform version && terraform fmt -diff -check -recursive
20+
21+
job2:
22+
name: Functionality
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- name: Init
28+
run: terraform init -backend=false
29+
30+
- name: Validate (Does not check variable values and variable validation logic)
31+
run: terraform validate

.github/workflows/yamllint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: YAML
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
12+
job1:
13+
name: yamllint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: yamllint
19+
uses: ibiqlik/action-yamllint@v3
20+
with:
21+
config_data: |
22+
extends: default
23+
rules:
24+
comments:
25+
require-starting-space: false
26+
comments-indentation: disable
27+
truthy:
28+
check-keys: false
29+
line-length: disable
30+
document-start: disable
31+
document-end: disable
32+
empty-lines:
33+
max: 2
34+
max-end: 2
35+
brackets:
36+
min-spaces-inside: 0
37+
max-spaces-inside: 4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.tfstate
2+
*.tfstate.*
3+
**/.terraform
4+
**/.terraform.*
5+
**/.env_sig.txt

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022, Brightbock Ltd.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
![GitHub](https://img.shields.io/github/license/brightbock/lambda-layers-python) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/brightbock/lambda-layers-python) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/brightbock/lambda-layers-python/terraform.yml?branch=main)
2+
3+
# Lambda Layers for Python
4+
5+
## How to use:
6+
7+
1. Add a module definition to your Terraform. See the example below.
8+
9+
```
10+
module "lambda_layers_python" {
11+
source = "git::https://github.com/brightbock/lambda-layers-python.git?ref=v0.1.0"
12+
# providers = { aws = aws.use1 }
13+
}
14+
```
15+

layer/make_package.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
PIP="$(which pip3)" || PIP="pip"
8+
9+
TMPDIR="$(mktemp -d -t lambda_package_layer.XXXXXXXXXX)" || exit 1
10+
11+
HERE="$(dirname "$( realpath "$0" )" )"
12+
13+
$PIP install --target "${TMPDIR}/python" -r "${HERE}/requirements.txt"
14+
15+
cd "${TMPDIR}"
16+
17+
rm -f "${HERE}/package.zip"
18+
19+
zip -r "${HERE}/package.zip" .
20+
21+
cd /
22+
23+
rm -rf "${TMPDIR}"

layer/package.zip

12 MB
Binary file not shown.

layer/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
boto3==1.26.144
2+
botocore==1.29.144
3+
requests==2.31.0

main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
locals {
2+
lambda_layer_dir = var.lambda_layer_dir == "" ? "${path.module}/layer" : var.lambda_layer_dir
3+
}
4+
5+
resource "aws_lambda_layer_version" "boto3_botocore_requests" {
6+
filename = "${local.lambda_layer_dir}/package.zip"
7+
source_code_hash = filebase64sha256("${local.lambda_layer_dir}/package.zip")
8+
layer_name = "boto3_botocore_requests"
9+
compatible_runtimes = ["python3.10", "python3.9"]
10+
compatible_architectures = ["arm64", "x86_64"]
11+
}
12+
13+
output "boto3_botocore_requests_arn" {
14+
value = aws_lambda_layer_version.boto3_botocore_requests.arn
15+
}

terraform.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
terraform {
2+
required_version = ">= 1.5.1"
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
version = ">= 5.5.0"
7+
}
8+
archive = {
9+
source = "hashicorp/archive"
10+
version = ">= 2.2.0"
11+
}
12+
local = {
13+
source = "hashicorp/local"
14+
version = ">= 2.2.0"
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)