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.
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
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.
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`.
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
Commit your initial project setup to the main branch and push it to GitHub:
git commit -m 'Initial project commit'
git push origin main
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,
});
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
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.
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.
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.
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.
Keep me up to date with content, updates, and offers from CloudKitect
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.
Keep me up to date with content, updates, and offers from CloudKitect