You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/integrations/infrastructure-as-code/terraform.mdx
-279Lines changed: 0 additions & 279 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,285 +239,6 @@ It will detect whether the AWS account ID is `000000000000`, which is the defaul
239
239
If you use a different account ID within LocalStack, you can customize the snippet accordingly.
240
240
:::
241
241
242
-
## CDK for Terraform
243
-
244
-
Cloud Development Kit for Terraform (CDKTF) allows you to use general-purpose programming languages, such as TypeScript, Python, Java, and more, to create infrastructure declaratively.
245
-
It allows you to create, update, and delete AWS infrastructure by leveraging a Terraform backend without manually configuring Terraform using HCL and [AWS Cloud Development Kit](https://aws.amazon.com/cdk/) to translate your code into infrastructure configuration files for Terraform.
246
-
CDKTF supports every Terraform provider and module available on the [Terraform Registry](https://registry.terraform.io/).
247
-
248
-
### Configuration
249
-
250
-
To configure your existing CDKTF configuration to work with LocalStack, manually configure the local service endpoints and credentials.
251
-
It includes:
252
-
253
-
- General configuration to specify mock credentials for the AWS provider (`region`, `access_key`, `secret_key`).
254
-
- Request Management to avoid issues with routing and authentication, if needed.
255
-
- Service configuration to point the individual services to LocalStack.
256
-
257
-
Here is a configuration example to use with Python & TypeScript CDKTF configurations:
Create a new directory named `cdktf-localstack` and initialize a new CDKTF project using the following command:
372
-
373
-
<Tabs>
374
-
<TabItemlabel="Python">
375
-
```python showshowLineNumbers
376
-
cdktf init
377
-
...
378
-
? Do you want to continuewith Terraform Cloud remote state management? No
379
-
? What template do you want to use? python
380
-
381
-
Initializing a project using the python template.
382
-
? Project Name sample-app
383
-
? Project Description A simple getting started project for cdktf.
384
-
? Do you want to start from an existing Terraform project? No
385
-
? Do you want to send crash reports to the CDKTF team? Refer to https://developer.hashicorp.com/terraform/cdktf/create-and-deploy/configuration-file#enable-crash-reporting-for-the-cli for more information no
386
-
Note: You can always add providers using 'cdktf provider add' later on
387
-
? What providers do you want to use? aws
388
-
...
389
-
```
390
-
</TabItem>
391
-
<TabItem label="TypeScript">
392
-
```javascript showshowLineNumbers
393
-
cdktf init
394
-
...
395
-
? Do you want to continuewith Terraform Cloud remote state management? No
396
-
? What template do you want to use? typescript
397
-
398
-
Initializing a project using the typescript template.
399
-
? Project Name sample-app
400
-
? Project Description A simple getting started project for cdktf.
401
-
? Do you want to start from an existing Terraform project? No
402
-
? Do you want to send crash reports to the CDKTF team? Refer to https://developer.hashicorp.com/terraform/cdktf/create-and-deploy/configuration-file#enable-crash-reporting-for-the-cli for more information no
403
-
Note: You can always add providers using 'cdktf provider add' later on
404
-
? What providers do you want to use? aws
405
-
...
406
-
```
407
-
</TabItem>
408
-
</Tabs>
409
-
410
-
(Optional) If necessary, we can install the AWS provider separately forCDKTF, by running the following command:
411
-
412
-
<Tabs>
413
-
<TabItem label="Python">
414
-
```python
415
-
pipenv install cdktf-cdktf-provider-aws
416
-
```
417
-
</TabItem>
418
-
<TabItem label="TypeScript">
419
-
```javascript
420
-
npm install @cdktf/provider-aws
421
-
```
422
-
</TabItem>
423
-
</Tabs>
424
-
425
-
Add the following code to import the AWS provider and create a new S3 bucket in the relevant file:
426
-
427
-
<Tabs>
428
-
<TabItem label="main.py">
429
-
```python showshowLineNumbers
430
-
# !/usr/bin/env python
431
-
432
-
from constructs import Construct
433
-
from cdktf import App, TerraformStack
434
-
from cdktf_cdktf_provider_aws.provider import AwsProvider
435
-
from cdktf_cdktf_provider_aws.s3_bucket import S3Bucket
Verify that the S3 bucket has been created successfully by running the following command:
514
-
515
-
```bash
516
-
awslocal s3 ls
517
-
```
518
-
519
-
Your CDKTF stack is now successfully deployed to LocalStack. You can now start using CDKTF to create and manage your AWS resources on LocalStack.
520
-
521
242
## OpenTofu
522
243
523
244
OpenTofu is an open-source fork of Terraform acting as a drop-in replacement for Terraform, as it's compatible with Terraform versions 1.5.x and most of 1.6.x. You can use OpenTofu with LocalStack to create and manage your AWS resources with your pre-existing Terraform configurations. You can use the `TF_CMD` environment variable with `tflocal` to specify the `tofu` binary to call, or setup a manual configuration to point the individual services to LocalStack.
0 commit comments