Streamline CDK Development with the Deployable CDK App Framework

Efficient software development is crucial for any organization striving to stay competitive in today’s market. Mature organizations adhere to well-defined software development standards, such as Gitflow, which involves the use of feature branches for development. Infrastructure as Code (IaC) can also benefit from these standards, especially when combined with a robust CI/CD pipeline. This blog post will guide you through developing an end-to-end CDK application using an open-source framework by CloudKitect Inc. called the Deployable CDK Application.

Pre-requisites

Before we start, ensure you have connected GitHub to your AWS account using OpenID Connect. AWS provides a small framework to set up your account quickly: GitHub Actions OIDC CDK Construct

Step 1: Setting Up the Project

To begin, create a new project using the scaffolding provided by the Deployable CDK Application framework. This framework leverages Projen, which allows you to define and maintain complex project configurations through code. Follow these steps to set up your project:

1. Create a new directory and navigate into it:

				
					mkdir my-project

  cd my-project
				
			

 

2. Initialize the project with Projen:

				
					npx projen new --from "@cloudkitect/deployable-cdk-app"
				
			

This command creates a Projen project with sensible defaults, including PR request templates, release versioning, and CI/CD pipelines for feature branches. You have the flexibility to change the defaults or add new project-specific configurations.

Step 2: Configuring the ProjenRC File

All changes to files managed by Projen will be done in the ProjenRC file (.projenrc.ts for TypeScript). Here is an example configuration:

				
					const project = new DeployableCdkApplication({
  name: 'my-test-app',
  defaultReleaseBranch: 'main',
  cdkVersion: '1.143.1',
  releaseConfigs: [{
    accountType: 'Dev',
    deploymentMethod: 'change-set',
    roleToAssume: 'role-arn',
    region: 'us-east-1',
  }],
});
				
			

The `releaseConfigs` allow developers to define various environments where the CDK app will be deployed. You can specify deployment methods such as `change-set`, `direct`, or `prepare-change-set`.

Step 3: Synthesizing the Project

After configuring the Projen file, run the following command to synthesize the project and create GitHub workflow actions for build and release pipelines:

				
					npx projen
				
			

Step 4: Initial Commit and Push

Commit your initial project setup to the main branch and push it to GitHub:

				
					git commit -m 'Initial project commit'
git push origin main
				
			

Step 5: Developing a Feature

Next, create a new branch for your feature development:

				
					git checkout -b feature-1
				
			

Implement your feature by updating the `MyStack` in `main.ts` with the necessary CDK constructs. For example, to create an S3 bucket:

				
					new s3.Bucket(this, 'MyBucket', {
  versioned: true,
});

				
			

Step 6: Building and Testing Locally

Run a local build to ensure everything works correctly:

				
					npx projen && npx projen build
				
			

 

If the build passes, commit and push your changes:

				
					git add -A
git commit -m 'feat: new bucket'
git push origin feature-1
				
			

Step 7: Creating a Pull Request

Go to GitHub and create a pull request. Once the pull request is created, it will trigger the CI/CD pipeline to build the feature branch. After the build passes, merge the pull request into the main branch. Merging will trigger the release process, creating a new release in GitHub and deploying the CDK resources to the defined environments.

Conclusion

Using the Deployable CDK Application framework simplifies the process of building, managing, and deploying CDK applications. By leveraging Projen and well-defined CI/CD pipelines, you can ensure efficient and reliable deployment of your infrastructure as code. This approach not only accelerates development but also maintains high standards of compliance and security.

For organizations looking to streamline their CDK development, the Deployable CDK Application by CloudKitect Inc. provides an excellent foundation to build upon.

Talk to Our Cloud/AI Experts

Name
Please let us know what's on your mind. Have a question for us? Ask away.
This field is for validation purposes and should be left unchanged.

Search Blog

About us

CloudKitect revolutionizes the way technology startups adopt cloud computing by providing innovative, secure, and cost-effective turnkey solution that fast-tracks the digital transformation. CloudKitect offers Cloud Architect as a Service.

Subscribe to our newsletter

Hidden

Next Steps: Sync an Email Add-On

To get the most out of your form, we suggest that you sync this form with an email add-on. To learn more about your email add-on options, visit the following page (https://www.gravityforms.com/the-8-best-email-plugins-for-wordpress-in-2020/). Important: Delete this tip before you publish the form.
Shopping Basket