[Terraform] CDKTF module apply
DONT FORGOT
aws configure
before do something!!!
Use PreBuilt
Use Terraform Module on CDKTF
Approach 1 - visit github ('Terraform AWS modules' github)
Approach 2 - visit Terraform registry
and pick what you need.
Provider Setup
let's begin with AWS provider setup
you can see name, source
put that info in cdktf.json
and type
after that, you can see .gen
directory, and able to import aws modules.
But it's just begun! It's not a module! It's a provider! Keep bare with this document
About Versioning OptionThere are several version constraint operators you can use in Terraform and package management systems. Here are the most common options:
Exact version:
"= 3.0.0"
- Only use exactly version 3.0.0Greater than:
"> 3.0.0"
- Use any version greater than 3.0.0Greater than or equal to:
">= 3.0.0"
- Use version 3.0.0 or any greater versionLess than:
"< 4.0.0"
- Use any version less than 4.0.0Less than or equal to:
"<= 3.9.9"
- Use any version up to and including 3.9.9Pessimistic constraint (allows only patch updates):
"~> 3.0.0"
- Use versions from 3.0.0 up to, but not including, 3.1.0Pessimistic constraint (allows minor and patch updates):
"~> 3.0"
- Use versions from 3.0.0 up to, but not including, 4.0.0Range constraint:
">= 3.0, < 4.0"
- Use any version from 3.0.0 up to, but not including, 4.0.0Wildcard constraints:
"3.*"
or"3.x"
- Any version in the 3.x seriesAny version:
"*"
or omitting the version - Use the latest version availableCombination: You can combine these for more specific ranges, e.g.,
">= 3.0, < 3.5"
When choosing a version constraint, consider:
How stable you need your infrastructure to be
How often you want to manually update and test new versions
The module's update frequency and backwards compatibility promises
For most cases, the pessimistic constraint (
~>
) offers a good balance between getting updates and maintaining stability. However, for critical infrastructure, you might want to pin to an exact version and update manually after thorough testing.
Import modules
this time, we will import vpc
module.
and add this info on cdktf.json
and run cdktf get
then you can see module.
add something like this on cdktf.json
and run cdktf get
Last updated
Was this helpful?