Skip to content

Instantly share code, notes, and snippets.

View yvesDenis's full-sized avatar
🎯
Focusing

Yves Denis Deffo yvesDenis

🎯
Focusing
View GitHub Profile
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- IMAGE_TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION:=latest}
- IMAGE_REPO_CREATE_URL=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_CREATE
- IMAGE_REPO_GET_URL=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_GET
#For your lambda to connect to a local dynamoDb , the two components should share the same docker network
#as sam build runs a docker process. The AWS endpoint inside your source code should be http://docker.for.mac.localhost:8000 for mac
# Or http://localhost:8000 for linux OS
default: docker_network docker_run aws_create_table aws_lambda_invoke
docker_network:
docker network create networktest
docker_run:
docker run -d -p 8000:8000 --network networktest --name dynamodblocal amazon/dynamodb-local
name: IAC codepipeline - codebuild
on:
push:
branches: [ "serverless-system-deploy" ]
env:
AWS_REGION: ca-central-1
ASSUME_ROLE: arn:aws:iam::516193157210:role/base-app-role
permissions:
name: 'Terragrunt GitHub Actions for base-app'
on:
push:
branches: [ "iac*" ]
env:
AWS_REGION: ca-central-1
ASSUME_ROLE: arn:aws:iam::516193157210:role/base-app-role
TFC_API_TOKEN: ${{ secrets.TFC_API_TOKEN }}
@yvesDenis
yvesDenis / Ecs_gist
Created December 11, 2022 20:16
ECR config
resource "aws_ecs_cluster_capacity_providers" "base_app_aws_ecs_cluster_capacity_providers" {
cluster_name = aws_ecs_cluster.base_app_aws_ecs_cluster.name
capacity_providers = [aws_ecs_capacity_provider.base_app_aws_ecs_capacity_provider.name,"FARGATE","FARGATE_SPOT"]
}
resource "aws_ecs_capacity_provider" "base_app_aws_ecs_capacity_provider" {
name = "base-app-capacity-provider"
auto_scaling_group_provider {
resource "aws_ecr_repository" "base-app-repository" {
name = "base-app-repo"
image_tag_mutability = "IMMUTABLE"
tags = {
name = "base-app"
subject = "github"
}
}
@yvesDenis
yvesDenis / Webhook_integration_gist
Created December 11, 2022 19:47
codebuild configuration
resource "aws_codebuild_webhook" "base_app_codebuild_webhook" {
project_name = aws_codebuild_project.base_app_codebuild.name
build_type = "BUILD"
filter_group {
filter {
type = "EVENT"
pattern = "PUSH,PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED"
}
}
}
@yvesDenis
yvesDenis / clit-run.go
Created November 27, 2022 02:44
cli-run
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
@yvesDenis
yvesDenis / flags-cli.go
Created November 27, 2022 02:43
cli-flags
Flags: []cli.Flag{
&cli.StringFlag{
Name: "key",
Aliases: []string{"k"},
Usage: "(Required)-Cypher key used for encryption/decryption, It's length should be a multiple of 16",
Destination: &key,
},
&cli.StringFlag{
Name: "text",
Aliases: []string{"t"},
@yvesDenis
yvesDenis / commands-cli.go
Last active November 27, 2022 02:42
cli-commands
Commands: []*cli.Command{
{
Name: "encrypt",
Aliases: []string{"e"},
Usage: "encrypt a text",
Action: func(*cli.Context) error {
cypherText, err := encryption.Encrypt(text, key)
if err != nil {
return cli.Exit("Input parameters are not valid for encryption, please provide valid key or text!", 86)
}