Skip to content

Instantly share code, notes, and snippets.

View michaelfecher's full-sized avatar
🦊
what the fox?!

Michael Fecher michaelfecher

🦊
what the fox?!
View GitHub Profile
@michaelfecher
michaelfecher / cdk_remove_hard_codings-using_env_vars.ts
Created October 31, 2020 13:02
AWS CDK - Configurabe values: Simple, independent (from deployment environment), but intransparent/
// source: https://github.com/michaelfecher/cdk-field-guide/blob/main/remove-hard-coded-values-and-use-variables/environment-variables/vpc-stack.ts
export class VpcStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// reading the value from the env.
// Obviously, you have to set it before or pass it before you call any cdk command
const vpcCidr = process.env.VPC_CIDR;
new Vpc(this, 'VPC', {
maxAzs: 3,
@michaelfecher
michaelfecher / cdk_code_organization_with_ecs.txt
Created September 1, 2020 13:41
CDK Code Organization with ECS
# ECS specific CDK code organization
repo-infra
|- pipeline (main cdk-app, stacks, taskdefinitions for app_A & app_B**)
|- app_A (buildspec, imports A specific stuff from pipeline)
|- app_B (buildspec, imports B specific stuff from pipeline)
repo-app_A
|- cicd (=> Build/Test + Docker Build/Push + ECR CodeDeploy)
@michaelfecher
michaelfecher / cross-account-code-pipeline-stack.ts
Created August 19, 2020 08:15
CDK CodePipeline/CodeBuild Cross Account Deployment Issue (permission denied)
import * as cdk from "@aws-cdk/core";
import * as codecommit from "@aws-cdk/aws-codecommit";
import * as codebuild from "@aws-cdk/aws-codebuild";
import * as codepipeline from "@aws-cdk/aws-codepipeline";
import * as codepipeline_actions from "@aws-cdk/aws-codepipeline-actions";
import * as iam from "@aws-cdk/aws-iam";
export class CrossAccountCodePipelineStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: cdk.StackProps) {
super(scope, id, props);
@michaelfecher
michaelfecher / backend-task-stack.ts
Created July 25, 2020 15:46
Blogpost: ECS Fargate with passing secrets - ECS Fargate Task Definition
// file: lib/backend-task-stack.ts
import * as cdk from "@aws-cdk/core";
import * as ecs from "@aws-cdk/aws-ecs";
import * as iam from "@aws-cdk/aws-iam";
import * as ecr from "@aws-cdk/aws-ecr";
import { DBCredentials } from "./db-credentials-stack";
export interface BackendStackProps extends cdk.StackProps {
backendPort: number;
dbEndpoint: string;
@michaelfecher
michaelfecher / db-credentials-stack.ts
Created July 25, 2020 15:42
Blogpost: ECS Fargate Passing secrets: DB credentials import in CDK
// file: lib/db-credentials-stack.ts
import { ISecret, Secret } from "@aws-cdk/aws-secretsmanager";
import * as cdk from "@aws-cdk/core";
export interface DBCredentials {
username: ISecret;
password: ISecret;
}
export class DbCredentialsStack extends cdk.Stack {
@michaelfecher
michaelfecher / rds-stack.ts
Created July 25, 2020 15:37
Blogpost: ECS Fargate Secret Usage, RDS part
// file: lib/rds-stack.ts
import * as cdk from "@aws-cdk/core";
import * as ec2 from "@aws-cdk/aws-ec2";
import * as rds from "@aws-cdk/aws-rds";
import { DBCredentials} from "./db-credentials-stack";
export interface RDSStackProps extends cdk.StackProps {
vpc: ec2.Vpc;
credentials: DBCredentials;
}
@michaelfecher
michaelfecher / keybase.md
Created February 12, 2019 09:25
keybase verification

Keybase proof

I hereby claim:

  • I am michaelfecher on github.
  • I am michaelfecher (https://keybase.io/michaelfecher) on keybase.
  • I have a public key ASA9tKMNEdTVaK20y4oNVAaB1P0Twzlk3G5OChZ29zP2aAo

To claim this, I am signing this object: