This file contains hidden or 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
data "template_file" "main" { | |
template = file("${path.module}/task_definition.json") | |
vars = { | |
ecr_image_url = var.repo_url | |
name = var.app | |
name_index_log = lower(var.app) | |
prefix_logs = var.prefix_logs | |
region = var.region | |
environment = jsonencode(concat(local.main_environment, var.environment_list)) |
This file contains hidden or 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
[ | |
{ | |
"essential": true, | |
"image": "${ecr_image_url}", | |
"name": "${name}", | |
"portMappings": [ | |
{ | |
"containerPort": ${port}, | |
"hostPort": ${port} | |
} |
This file contains hidden or 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
resource "null_resource" "docker_packaging" { | |
provisioner "local-exec" { | |
command = <<EOF | |
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${data.aws_caller_identity.current.account_id}.dkr.ecr.us-east-1.amazonaws.com | |
gradle build -p noiselesstech | |
docker build -t "${aws_ecr_repository.noiselesstech.repository_url}:latest" -f noiselesstech/Dockerfile . | |
docker push "${aws_ecr_repository.noiselesstech.repository_url}:latest" | |
EOF | |
} |
This file contains hidden or 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
resource "aws_ecr_lifecycle_policy" "default_policy" { | |
repository = aws_ecr_repository.noiselesstech.name | |
policy = <<EOF | |
{ | |
"rules": [ | |
{ | |
"rulePriority": 1, | |
"description": "Keep only the last ${var.untagged_images} untagged images.", | |
"selection": { |
This file contains hidden or 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
resource "aws_ecr_repository" "noiselesstech" { | |
name = "noiselesstech" | |
image_scanning_configuration { | |
scan_on_push = true | |
} | |
} |
This file contains hidden or 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
output "result_lambda_invocation" { | |
value = aws_lambda_invocation.lambda_invocation.result | |
} |
This file contains hidden or 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
resource "aws_lambda_invocation" "lambda_invocation" { | |
function_name = "NoiselesstechExample" | |
input = jsonencode({ | |
hello = "world" | |
data = "my super data" | |
goodbye = "see you" | |
}) | |
triggers = { |
This file contains hidden or 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
const logger = require('pino')(); | |
exports.handler = async (event, context) => { | |
context.callbackWaitsForEmptyEventLoop = false; | |
const dataEvent = JSON.stringify(event); | |
logger.info('Display data event: '+ dataEvent); | |
return context.succeed({ data: dataEvent }); | |
}; |
This file contains hidden or 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
module "lambda_noiselesstech" { | |
source = "../terraform-aws-lambda" // A public registry path is allowed too | |
code_location = "./lambdas/example" | |
filename = "example.zip" | |
lambda_function_name = "NoiselesstechExample" | |
lambda_runtime = "nodejs14.x" | |
layer_arn = module.layer.arn | |
environment_variables = { |
This file contains hidden or 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
resource "null_resource" "main" { | |
triggers = { | |
updated_at = timestamp() | |
} | |
provisioner "local-exec" { | |
command = <<EOF | |
yarn config set no-progress | |
yarn |