🎤 An example that showcases how using the CDK for Terraform allows easy management of your Kubernetes cluster and overall AWS infrastructure without impacting your applications.
APACHE-2.0 License
Showcasing how to use the CDK for Terraform to create a VPC, EKS cluster, and use Fargate for compute
To use the code in this repository, you will need the following applications:
4.4.x
(or later)0.8.x
(or later)2.4.x
(or later)For this example, you will need to ensure that you have all the required dependencies installed, and which are listed above.
Once you have all the dependencies installed, please ensure that you update your Terraform Cloud Remote Backend to match what you have set up in Terraform Cloud.
Also, ensure that you have set up your AWS credentials in Terraform Cloud so that it can execute runs on your behalf.
You should set at least the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
variables in Terraform Cloud as "Workspace variables." While I recommend both should be set as "sensitive" values, I encourage you use your best judgement, or consult your security team for more information on how to set up your credentials.
To run this code, please follow all the steps above, including making sure you have set up and configured all dependencies.
cdktf get
- this pulls down all the correct dependencies for your project.cdktf synth
- this synthesizes and creates the code bindings you need for all of the project's CDK code .cdktf diff
- this is like terraform plan
and will show you what is expected to get created during the next step.cdktf deploy
- this is like terraform apply
and will create the resources you saw during the previous step.If you'd like to interact with the EKS cluster you instantiated, you can run this command to get the correct kubectl
configuration on your machine.
aws eks update-kubeconfig --name optimize
I have included an application.yaml
file that you can use to deploy to your EKS cluster and test your Fargate workloads and validate the selectors within our CDK for Terraform code.
Once you are done and no longer have a use for the infrastructure, you stood up, you can run cdktf destroy
to remove the infrastructure you created.
This repository is maintained by Taylor Dolezal
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
See the License for the specific language governing permissions and limitations under the License.