Skip to content

Instantly share code, notes, and snippets.

@shar1z
Created December 8, 2022 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shar1z/c6140909b9eaa9e1409f895dc8c8fe0b to your computer and use it in GitHub Desktop.
Save shar1z/c6140909b9eaa9e1409f895dc8c8fe0b to your computer and use it in GitHub Desktop.
chatgpt.hcl
provider "aws" {
region = "us-east-1"
}
# Create an EKS cluster
resource "aws_eks_cluster" "eks_cluster" {
name = "my-eks-cluster"
role_arn = aws_iam_role.eks_cluster_role.arn
}
# Create an IAM role for the EKS cluster
resource "aws_iam_role" "eks_cluster_role" {
name = "eks-cluster-role"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}
# Attach the AmazonEKSClusterPolicy policy to the EKS cluster role
resource "aws_iam_role_policy_attachment" "eks_cluster_policy_attachment" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
}
# Create an Amazon Elastic Block Store (EBS) volume for the Kubernetes etcd data
resource "aws_ebs_volume" "eks_etcd_volume" {
availability_zone = aws_instance.eks_control_plane.availability_zone
size = 20
type = "gp2"
}
# Create an Amazon Elastic Compute Cloud (EC2) instance for the Kubernetes control plane
resource "aws_instance" "eks_control_plane" {
ami = "ami-0ac019f4fcb7cb7e6"
instance_type = "t3.medium"
subnet_id = aws_subnet.eks_control_plane_subnet.id
iam_instance_profile = aws_iam_instance_profile.eks_control_plane_instance_profile.name
key_name = "my-ssh-key"
root_block_device {
volume_type = "gp2"
volume_size = 20
delete_on_termination = true
}
tags = {
Name = "eks-control-plane"
}
}
# Create an IAM instance profile for the Kubernetes control plane EC2 instance
resource "aws_iam_instance_profile" "eks_control_plane_instance_profile" {
name = "eks-control-plane-instance-profile"
role = aws_iam_role.eks_control_plane_role.name
}
# Create an IAM role for the Kubernetes control plane EC2 instance
resource "aws_iam_role" "eks_control_plane_role" {
name = "eks-control-plane-role"
assume_role_policy = <<POL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment