This repository contains a Pulumi kit to create AWS resources written in TypeScript.
Currently this code will create the following resources:
- VPC
- 3 public subnets
- 3 private subnets
- Internet Gateway
- NAT Gateway
- Route tables
- KMS
- KMS key
- KMS key alias
- EKS
- 4 self-managed addons
- EKS-managed nodegroup
In the awsx folder there are modules created with Pulumi's AWSX library. It is working as well, but currently not used in this code. Instead we are using Pulumi AWS Classic library
To run this code successfully you need to install pulumi on your local machine.
Follow the instructions from Pulumi's website to do so:
https://www.pulumi.com/docs/install/
To install the latest the latest npm and Node version:
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
In the package.json file you can define the entry point of Pulumi (index.ts by default), the desired Node version and the required dependency packages.
You have to install @pulumi/pulumi and @pulumi/aws packages for this stack.
For installation enter the directory of package.json and run:
npm install
{
"name": "aws-starter-kit",
"version": "1.0.0",
"main": "index.ts",
"devDependencies": {
"@types/node": "^16"
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"@pulumi/aws": "^6.7.0"
}
}
As this code will create resources in AWS you need to configure your AWS profile credendials. Pulumi will use these credentials by default.
- Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
- Configure AWS profile: https://docs.aws.amazon.com/cli/latest/reference/configure/
To modify AWS resources to fit your needs (e.g. change CIDR values, availability zones, number of subnets, etc...) open the Pulumi.dev.yaml and Pulumi.prod.yaml file and modify the values there. This files contain the variables used by the code in different environments.
There are currently 2 different environments in this project, a dev and a prod. Before running the code you have to create a stack for both environments.
pulumi stack init dev
pulumi stack init prod
Now you can change between these stack and Pulumi will automatically use the corresponding yaml file to read the variables. To change between stacks:
pulumi stack select dev
pulumi stack select prod
After your environment is configured:
- Clone this repository
- Enter the node directory
- Run command: pulumi up
This command will first check if the pulumi configuration is valid and the resources can be created. If everything is fine you can select yes in your terminal and the resources will be created in a few minutes.
To destroy the stack that Pulumi created just run:
pulumi destroy