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
#!/bin/bash | |
export AWS_PAGER="" | |
delete_repo() { | |
local ecr_type=$1 | |
local repo=$2 | |
echo "Deleting images in $ecr_type repository: $repo" | |
images=$(aws $ecr_type describe-images --repository-name $repo --query 'imageDetails[*].[imageDigest]' --output text) |
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
import boto3 | |
def lambda_handler(event, context): | |
client = boto3.client('ec2') | |
# ec2_regions = [region['RegionName'] for region in client.describe_regions()['Regions']] | |
ec2_regions = ["us-east-1", "us-east-2", "us-west-1", "us-west-2"] | |
for region in ec2_regions: | |
ec2 = boto3.resource('ec2',region_name=region) | |
instances = ec2.instances.filter(Filters=[{'Name': 'instance-state-name', 'Values': ['running']}]) | |
RunningInstances = [instance.id for instance in instances] | |
for i in RunningInstances: |
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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: deployment-hello-world | |
spec: | |
selector: | |
matchLabels: &pod-label | |
run: pod-hello-world | |
template: | |
metadata: |
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
################################################ | |
# Lambda Resources Option 3 - Multiple Lambdas | |
################################################ | |
#In this scenario the Lambda is zipped and upload outside of the terraform execution | |
resource "aws_lambda_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
s3_key = local.signedSourceList[index(local.trimPrefix, "lambda")] | |
# ^ Returns "signed/lambda-3ed11736-6655-4448-935d-659cd0428b90.zip" | |
.... | |
.... |
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
####################################### | |
# Lambda Resources Option 3 | |
####################################### | |
#In this scenario the Lambda is zipped and upload outside of the terraform execution | |
resource "aws_lambda_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
# s3_key = aws_signer_signing_job.build_signing_job.signed_object[0]["s3"][0]["key"] | |
s3_key = local.lambdaSource | |
function_name = var.lambda-name | |
handler = "lambda_function.lambda_handler" |
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
###################################### | |
# Lambda Resources Option 2 | |
###################################### | |
resource "aws_lambda_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
s3_key = aws_signer_signing_job.build_signing_job.signed_object[0]["s3"][0]["key"] | |
function_name = var.lambda-name | |
handler = "lambda_function.lambda_handler" | |
memory_size = 128 | |
runtime = "python3.8" |
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
##################################### | |
Lambda Resources Option 1 | |
##################################### | |
resource "aws_lambda_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
s3_key = aws_signer_signing_job.build_signing_job.signed_object[0]["s3"][0]["key"] | |
..... | |
..... | |
code_signing_config_arn = aws_lambda_code_signing_config.abc-signer-profile-config.arn |
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
###################################### | |
Lambda Resources Option 1 | |
###################################### | |
resource "aws_lambda_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
s3_key = aws_signer_signing_job.build_signing_job.signed_object[0]["s3"][0]["key"] | |
function_name = var.lambda-name | |
handler = "lambda_function.lambda_handler" | |
memory_size = 128 | |
runtime = "python3.8" |
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_function" "test_lambda" { | |
s3_bucket = var.code-bucket | |
..... | |
..... | |
code_signing_config_arn = aws_lambda_code_signing_config.abc-signer-profile-config.arn | |
} |
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
############################################## | |
# Code Signing Resources Option 1 & Option 2 | |
############################################# | |
resource "aws_signer_signing_profile" "abc-signer-profile" { | |
name_prefix = "abc_" | |
platform_id = "AWSLambda-SHA384-ECDSA" | |
tags = var.tags | |
} |
NewerOlder