This guide walks you through the setup of a Pulumi project that creates an AWS EKS cluster along with the necessary VPC configurations and a bastion host for secure access. We will use Pulumi with Python, configure AWS CLI, and set up kubectl to interact with the EKS cluster.
Prerequisites:
- AWS Account
- Git installed on your machine
- Python installed on your machine
Install the AWS CLI to interact with AWS services directly from your terminal: macOS:
brew install awscli
Linux:
sudo apt-get install awscli
Windows: Download from AWS CLI and install using the provided installer.
Configure AWS CLI:
aws configure
This command will prompt you to enter your AWS credentials which include:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name
- Default output format
Install Pulumi to manage your infrastructure as code:
macOS and Linux:
curl -fsSL https://get.pulumi.com | sh
Windows: Download the installer from Pulumi's website.
Set up the Pulumi project:
pulumi new python
This command creates a new Pulumi project in Python and includes initializing a virtual environment and installing the pulumi Python package.
Install kubectl to manage the Kubernetes cluster:
macOS:
brew install kubectl
Linux:
sudo apt-get install kubectl
Windows: Download from Kubernetes.io and follow the installation instructions.
Clone the GitHub repository where the Pulumi project is located:
git clone https://github.com/novandrautomo17/iaac-pulumi.git
cd iaac-pulumi
Set up Python environment:
Install Python dependencies:
pip install -r requirements.txt
Initialize a new stack (if not already done):
pulumi stack init dev
Set the AWS region:
pulumi config set aws:region ap-southeast-1 #change the region accordingly
pulumi preview
pulumi up
pulumi stack output kubeconfig > kubeconfig.yaml
export KUBECONFIG=$PWD/kubeconfig.yaml
kubectl get nodes
To destroy the resources:
pulumi destroy
To remove the stack:
pulumi stack rm dev