A new platform for documentation and tutorials is launching soon.
We are migrating Terraform documentation into HashiCorp Developer, our new developer experience.
Search Terraform documentation Update your import statements for the AWS provider and learn to migrate your projects.
» AWS Provider has namespaced resourcesThe AWS Provider has a size that makes it hard to navigate in editors, especially in languages that compile it to a single file like Python. We implemented namespaces that hold Resources and Data Sources the same category together, and the categories are available on the AWS Provider page .
If you don't use the AWS provider no action is needed. If you do use the AWS provider, you need to adjust your import statements to match the namespaces.
» TypescriptFor Typescript you need to change the imports and reference the namespace
import { CloudFrontDistribution , AwsProvider , Route53Record , AcmCertificateValidation } from "./.gen/providers/aws" ;
import { CloudFront , AwsProvider , Route53 , ACM } from "./.gen/providers/aws" ;
new Route53Record ( this , "CertValidationRecord" , ... )
new Route53 . Route53Record ( this , "CertValidationRecord" , ... )
import { CloudFrontDistribution , AwsProvider , Route53Record , AcmCertificateValidation } from "./.gen/providers/aws" ;
import { CloudFront , AwsProvider , Route53 , ACM } from "./.gen/providers/aws" ;
new Route53Record ( this , "CertValidationRecord" , ... )
new Route53 . Route53Record ( this , "CertValidationRecord" , ... )
Alternatively you can deconstruct the namespace:
import {
CloudFrontDistribution ,
AwsProvider ,
Route53Record ,
AcmCertificateValidation ,
} from "./.gen/providers/aws" ;
import { CloudFront , AwsProvider , Route53 , ACM } from "./.gen/providers/aws" ;
const { CloudFrontDistribution } = CloudFront ;
const { Route53Record } = Route53 ;
const { AcmCertificateValidation } = ACM ;
import {
CloudFrontDistribution ,
AwsProvider ,
Route53Record ,
AcmCertificateValidation ,
} from "./.gen/providers/aws" ;
import { CloudFront , AwsProvider , Route53 , ACM } from "./.gen/providers/aws" ;
const { CloudFrontDistribution } = CloudFront ;
const { Route53Record } = Route53 ;
const { AcmCertificateValidation } = ACM ;
» PythonFor Python only the imports need to be changed:
from imports. aws import AwsProvider, SnsTopic
from imports. aws import AwsProvider
from imports. aws. sns import SnsTopic
from imports. aws import AwsProvider, SnsTopic
from imports. aws import AwsProvider
from imports. aws. sns import SnsTopic
For C# only the imports need to be changed:
using aws ;
using aws ;
using aws. sns ;
using aws ;
using aws ;
using aws. sns ;
» JavaFor Java only the imports need to be changed:
import imports. aws. AwsProvider ;
import imports. aws. SnsTopic ;
import imports. aws. AwsProvider ;
import imports. aws. sns. SnsTopic ;
import imports. aws. AwsProvider ;
import imports. aws. SnsTopic ;
import imports. aws. AwsProvider ;
import imports. aws. sns. SnsTopic ;
For Go only the imports need to be changed:
import (
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
"github.com/hashicorp/terraform-cdk-go/cdktf"
)
import (
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws"
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws/ec2"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
"github.com/hashicorp/terraform-cdk-go/cdktf"
)
import (
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
"github.com/hashicorp/terraform-cdk-go/cdktf"
)
import (
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws"
"github.com/hashicorp/terraform-cdk/examples/go/aws/generated/hashicorp/aws/ec2"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
"github.com/hashicorp/terraform-cdk-go/cdktf"
)
» Simplify Provider API SurfaceWhen generating the provider bindings we previously translated any block to an array of a certain type, both in configuration and as properties on the resource / data source instances. For blocks that can only appear once at most this is making the API harder to use. From this version on these blocks are going to be just the type instead of an array of a certain type.
To migrate you need to update the cdktf
and cdktf-cli
version you are using to 0.7 and run cdktf get
in your project. The new bindings might use fewer arrays in the configuration than before, depending on the schema of the providers you use. The typesystem and cdktf synth
will guide your migration.
The benefit of this change is that object properties can be accessed directly, e.g.
const development = new Namespace ( this , "development" , {
metadata: [
{
name: "development" ,
} ,
] ,
} ) ;
const deploy = new Deployment ( this , "nginx" , {
metadata: [
{
namespace: "setViaOverride" ,
name: "nginx" ,
} ,
] ,
} ) ;
deploy. addOverride (
"metadata.0.namespace" ,
` \${ ${ development. fqn } .metadata.0.name} `
) ;
const development = new Namespace ( this , "development" , {
metadata: {
name: "development" ,
} ,
} ) ;
new Deployment ( this , "nginx" , {
metadata: {
namespace: development. metadata . namespace ,
name: "nginx" ,
} ,
} ) ;
const development = new Namespace ( this , "development" , {
metadata: [
{
name: "development" ,
} ,
] ,
} ) ;
const deploy = new Deployment ( this , "nginx" , {
metadata: [
{
namespace: "setViaOverride" ,
name: "nginx" ,
} ,
] ,
} ) ;
deploy. addOverride (
"metadata.0.namespace" ,
` \${ ${ development. fqn } .metadata.0.name} `
) ;
const development = new Namespace ( this , "development" , {
metadata: {
name: "development" ,
} ,
} ) ;
new Deployment ( this , "nginx" , {
metadata: {
namespace: development. metadata . namespace ,
name: "nginx" ,
} ,
} ) ;