Coder Social home page Coder Social logo

productiveanalytics / aws-cdk-constructs-sandbox Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 5.62 MB

Cloud Development Kit (AWS CDK) using TypeScript, Python and Java

Java 81.52% Python 16.69% Shell 1.79%
java8 python3 aws-cdk cdk-constructs aws-glue aws-glue-crawler aws-athena aws-kinesis-firehose aws-kinesis firehose

aws-cdk-constructs-sandbox's Introduction

AWS CDK setup, (Python, TypeScript and Java)

  1. Install/Upgrade AWS CDK

1.a) Install AWS CDK

npm install -g aws-cdk 
# or use specific version like:  npm install -g [email protected]

1.b) Create starter project

mkdir -p my-cdk/python/ && cd my-cdk/python/
cdk init --language python
  1. Set-up generic CDK environments like AWS account and Region
export CDK_NEW_BOOTSTRAP=1
export CDK_DEBUG=true
export CDK_DEFAULT_ACCOUNT="<aws-account-id>"
export CDK_DEFAULT_REGION="us-east-1"

Tip : Get account-id using aws sts get-caller-identity

MY_AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
if [[ -z "$MY_AWS_ACCOUNT_ID" ]]
then
  echo "Defaulting Account ID...Otherwise, first run: aws-saml-auth"
  MY_AWS_ACCOUNT_ID="<my-static-aws-account-id-here>"
else
  echo "aws sts get-caller-identity"
  aws sts get-caller-identity
fi
  1. Set-up application-specific context parameters

Note: MUST match qualifier that is present in cdk.json present in the application-stack or update cdk.json with the qualifier you prefer.

Tip:Refer to the contexts set by cdk.json, execute cdk context --json

export CDK_CONTEXT_QUALIFIER=datasync
export CDK_CONTEXT_ENV_NAME=sbx
export CDK_CONTEXT_MODULE_NAME=con-test
export CDK_CONTEXT_ZONE_NAME=landing
  1. Confirm AWS session CDK command need AWS connection and access to S3, CFN execution role, etc. Ensure that the AWS session has been established and the executor has valid role. Most CDK commands stall and give a weird error, if the underlying AWS session has expired. For local, ensure to relogin using aws-saml-auth

Confirm by:

aws sts get-caller-identity
  1. ONE TIME CDK bootstrap activity per account per region Note: Note: Use toolkit-stack-name that is specific for each stack
cdk bootstrap aws://${CDK_DEFAULT_ACCOUNT}/${CDK_DEFAULT_REGION} \
--trust 887847050650 --trust-for-lookup 887847050650 \
--cloudformation-execution-policies arn:aws:iam::887847050650:policy/dtci-admin \
--qualifier ${CDK_CONTEXT_QUALIFIER} \
--toolkit-stack-name laap-cdk-toolkit-datasync-${CDK_CONTEXT_QUALIFIER}-stack \
--tags author=LDC --tags usage=datasync --tags module=${CDK_CONTEXT_MODULE_NAME} --tags qualifier=${CDK_CONTEXT_QUALIFIER} \
--force
  1. Confirm CDK environment settings
cdk doctor
  1. Build Library / Building Blocks as a jar
mvn clean install -DskipTests
  1. Build Application stack e.g. datasync stack, using the library jar
mvn --offline clean install -DskipTests
  1. Checkout CDK stacks
cdk \
--toolkit-stack-name laap-cdk-toolkit-datasync-${CDK_CONTEXT_QUALIFIER}-stack \
--context qualifier=${CDK_CONTEXT_QUALIFIER} \
--context aws_env_name=${CDK_CONTEXT_ENV_NAME} \
--context module_name=${CDK_CONTEXT_MODULE_NAME} \
--context zone_name=${CDK_CONTEXT_ZONE_NAME} \
ls

The output looks like,

  • My-datasync-con-test-landing-GlueCdkStack-sbx
  • My-datasync07-con-test-landing-FirehoseCdkStack-sbx
  • My-datasync07-con-test-landing-LambdaCdkStack-sbx
  1. Check the desired changes / updates
cdk \
--toolkit-stack-name laap-cdk-toolkit-datasync-${CDK_CONTEXT_QUALIFIER}-stack \
--context qualifier=${CDK_CONTEXT_QUALIFIER} \
--context aws_env_name=${CDK_CONTEXT_ENV_NAME} \
--context module_name=${CDK_CONTEXT_MODULE_NAME} \
--context zone_name=${CDK_CONTEXT_ZONE_NAME} \
diff
  1. Perform CDK deploy
cdk \
--toolkit-stack-name laap-cdk-toolkit-datasync-${CDK_CONTEXT_QUALIFIER}-stack \
--context qualifier=${CDK_CONTEXT_QUALIFIER} \
--context aws_env_name=${CDK_CONTEXT_ENV_NAME} \
--context module_name=${CDK_CONTEXT_MODULE_NAME} \
--context zone_name=${CDK_CONTEXT_ZONE_NAME} \
--parameters rolename=my-iam-role-data-gen-firehose-sbx \
--parameters topicss3bucket=my-s3-bucket-repository-sbx --parameters topicsfolder=not_needed_for_local_schemas \
--staging \
--require-approval never \
--progress events \
deploy --all

aws-cdk-constructs-sandbox's People

Contributors

productiveanalytics avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.