2025-06-08 AWS CLI EKS

K8s

  • create vpc ` $ aws --profile kp-admin ec2 create-vpc --cidr-block 10.0.0.0/16 { "Vpc": { "OwnerId": "379413463976", "InstanceTenancy": "default", "Ipv6CidrBlockAssociationSet": [], "CidrBlockAssociationSet": [ { "AssociationId": "vpc-cidr-assoc-04e63f23dba94c0d0", "CidrBlock": "10.0.0.0/16", "CidrBlockState": { "State": "associated" } } ], "IsDefault": false, "VpcId": "vpc-07140f15640aecf32", "State": "pending", "CidrBlock": "10.0.0.0/16", "DhcpOptionsId": "dopt-dc1e55b4" } } `

Create bastion with terraform

  • S3 bucket for state: ` $ aws --profile kp-admin s3 mb s3://$(date +%Y%m%d)-kp-eks-terraform-state --region eu-west-2 make_bucket: 20250609-kp-eks-terraform-state `

  • create dynamodb table for state lock ` aws --profile kp-admin dynamodb create-table --table-name kp-eks-terraform-locks --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --region eu-west-2 { "TableDescription": { "AttributeDefinitions": [ { "AttributeName": "LockID", "AttributeType": "S" } ], "TableName": "kp-eks-terraform-locks", "KeySchema": [ { "AttributeName": "LockID", "KeyType": "HASH" } ], "TableStatus": "CREATING", "CreationDateTime": "2025-06-09T21:46:41.011000+01:00", "ProvisionedThroughput": { "NumberOfDecreasesToday": 0, "ReadCapacityUnits": 5, "WriteCapacityUnits": 5 }, "TableSizeBytes": 0, "ItemCount": 0, "TableArn": "arn:aws:dynamodb:eu-west-2:379413463976:table/kp-eks-terraform-locks", "TableId": "38266a2a-8e37-4aeb-a436-76829cfe5c60", "DeletionProtectionEnabled": false } } `

  • use Warp to gen terraform

  • Run: terraform apply

  • Connect: ssh -i ~/.ssh/id_rsa ec2-user@<BASTION_PUBLIC_IP>

  • Cleanup: terraform destroy