Mastering AWS CDK: Initial AWS Account Configuration Steps
AWS Account Setup: Key to Successful AWS CDK Deployment #
This tutorial provides step-by-step instructions on how to configure an AWS account and its permissions to use with AWS CDK.
Introduction #
I have a project that requires the deployment of a cloud infrastructure on AWS. The infrastructure consists of several containers that communicate via Kafka. As a proponent of “Infrastructure as Code,” I will implement this infrastructure with AWS CDK.
To use AWS CDK, we need to first have an AWS account with the necessary permissions.
As a software engineer, I write code on a daily basis. Therefore, it is natural for me to “model” a cloud infrastructure via code. The great thing is that I can execute this code and obtain a fully working infrastructure as a result.
Prerequisites #
Assuming you are already the root user of an AWS account, we can dive right into configuring it. Please be aware that setting up such an infrastructure does cost money, so you will need to have a credit card linked to your account.
Background #
Infrastructure as Code (IaC) is a practice of defining and managing cloud infrastructure through code. This allows for the automation of infrastructure deployment and management, making it more reliable, scalable, and efficient. With IaC, infrastructure can be versioned, tested, and deployed in a repeatable and consistent manner, reducing the chances of errors and increasing the speed of deployment. Compared to manually managing cloud infrastructure, IaC provides better control, reduces the risk of human error, and improves collaboration between development and operations teams.
The AWS Cloud Development Kit (CDK) is a software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. It allows you to model your infrastructure using familiar programming languages such as TypeScript, Python, and Java, which enables you to apply software development practices such as version control, code review, and automated testing to your infrastructure as well. By using AWS CDK, you can define your infrastructure as code and deploy it to the cloud with ease, making it easier to manage and scale your cloud resources. AWS CDK is a key element of the Infrastructure as Code (IaC) approach, which involves defining infrastructure through code, enabling automation, repeatability, and consistency in infrastructure deployment.
Step-by-Step Guide #
Here is a rough overview of what we are going to do:
- Add a new IAM user.
- Create an Access Key ID and Access Key.
- Create a group and assign the user to this group.
To use AWS CDK, you need an access key. While you could create one using your root user, this is generally a bad idea. If you attempt to do so, AWS will warn you accordingly:
Let’s go to the IAM dashboard.
Next, click on “Users.”
And then “Add users.”
To proceed, enter the user’s name (in this case, “cdk-user”) and click “Next”.
Next, we need to assign some permissions to the user.
I left everything as it was and clicked on “Create User”. We will create the group later.
Store this information in a secure location and proceed with “Return to user list”.
To create a new access key for the user, select the user and click on “Create access key”.
You can then choose from several options for how we want to use the key.
I left everything as it was and clicked “Next.”
However, I am not sure what the second alternative is about or how it differs from the method explained here. I will investigate that at another time.
To complete the creation process, click on “Create access key”.
Now it is time to assign the required permissions to the user.
Click on “Add permissions.”
Click on “Create group” and select “AWSCloudFormationFullAccess” and “AdministratorAccess” to grant the necessary permissions.
Click on “Create user group.”
Here we add the user “cdk-user” to the group.
We are finally done by clicking “Add permissions”.
Conclusion #
This document provided a step-by-step guide on how to configure an AWS account and its permissions to use with AWS CDK. In the next tutorial, we will use the access key generated in this tutorial to deploy an infrastructure with AWS CDK.
Thank you for reading!
- If you enjoyed this, please follow me on Medium.
- Buy me a coffee or send me a tip.
- Support me and other Medium writers by signing up here.
https://twissmueller.medium.com/membership
This tutorial was created with the assistance of AI technology.