Converts CloudFormation resources to Terraform resources.
THIS IS A PROTOTYPE.
import { TerraformMapper } from 'cfn2tf';
const bucketMapper = new TerraformMapper('AWS::S3::Bucket');
equal(
bucketMapper.terraformResourceType,
'aws_s3_bucket'
);
const tfprops = bucketMapper.toTerraformProps({
BucketName: 'my-bucket',
VersioningConfiguration: { Status: 'Enabled' },
WebsiteConfiguration: {
IndexDocument: 'index.html',
}
});
equal(tfprops, {
bucket: 'foo',
versioning: [ { enabled: true } ],
website: [ { indexDocument: 'index.html' } ],
});
equal(
bucketMapper.toTerraformAttribute('RegionalDomainName'),
'bucket_regional_domain_name'
);Returns the a mapper associated with the specified CFN resource type (e.g. AWS::S3::Bucket).
Returns the Terraform resource type name (in the AWS provider) (e.g. aws_s3_bucket).
Converts an object with CloudFormation resource properties to Terraform semantics.
Throws an error if one of the properties could not be mapped.
Returns the name of the corresponding Terraform resource attribute (e.g. RegionalDomainName => bucket_regional_domain_name).
This project heavily relies on contributions to succeed. See the src/mapping directory to add mappings.
- Add "fuzz" testing to ensure property handlers are only picking up their own properties.
- Allow adding mapping if mapping is missing.
- Generate types to make it safer to write mappers
- Generate input property types from CloudFormation spec (steal from awscdk)
- Generate output property types from Terraform specs (steal from cdktf)
- Generate input attribute types
- Generate output attribute types
- Generate scaffolding for all CFN resource types with "not implemented"
- See if we can use heuristics to deduce mapping in certain cases
- Take a complex CDK L2 example (e.g. ECS) and implement all the mappers for it
- Create some helpers like
pick(obj, jsonpath)which return the value atjsonpathand delete it from the object.
Distributed under the Apache 2.0 License.