Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting AWS Data Pipeline as CloudFormation template to use it in Terraform

I'm trying to export existing AWS Data Pipeline task to Terraform infrastructure somehow.

Accordingly, to this issue, there is no direct support for Data Pipelines, but it still seems achievable using CloudFormation templates (terraform resource).

The problem is that I cannot find a way to export existing pipeline into CloudFormation template.

Exporting the pipeline with its specific definition syntax won't work as I've not found a way to include this definition into CloudFormation. CloudFormer does not support exporting pipelines either.

Does anybody know how to export a pipeline to CloudFormation or any other way to get AWS Data Pipeline automated with Terraform?

Thank you for your help!

like image 992
sorjef Avatar asked Jul 18 '17 10:07

sorjef


People also ask

Can you use CloudFormation with Terraform?

While you can use Terraform to manage CloudFormation stacks, when managing other resources (e.g. EC2 or EKS) it doesn't interact with CF at all and just uses the standard APIs for whatever service you are managing. CloudFormation could not exist and Terraform would still work happily.

Is Terraform alternative to CloudFormation?

Both CloudFormation and Terraform are flexible and compelling tools and offer comprehensive state management and automated logging. But they also provide different features that suit your infrastructure needs differently. If you're mainly working with AWS resources, CloudFormation might work best for you.

What is the difference between CloudFormation and Terraform?

Terraform modules can be pulled in for any provider supported, or organizations can roll their own. Conversely, in a multi-cloud or hybrid environment, CloudFormation doesn't easily allow users to provision or natively coordinate non-AWS resources.


1 Answers

UPD [Jul. 2019]: Some progress has been made in the terraform repository. aws_datapipeline_pipeline resource has been implemented, but it is not yet clear how to use it. Merged pull request

Original answer:

As a solution to this problem, I've come up with a node.js script, which covers my use case. In addition, I've created a Terraform module to be used in Terraform configuration.

Here is the link to the gist with the code

Will copy usage examples here.

Command Line:

node converter-cli.js ./template.json "Data Pipeline Cool Name" "Data Pipeline Cool Description" "true" >> cloudformation.json

Terraform:

module "some_cool_pipeline" {
  source = "./pipeline"
  name = "cool-pipeline"
  description = "The best pipeline!"
  activate = true
  template = "${file("./cool-pipeline-template.json")}"

  values = {
    myDatabase = "some_database",
    myUsername = "${var.db_user}",
    myPassword = "${var.db_password}",
    myTableName = "some_table",
  }
}
like image 183
sorjef Avatar answered Oct 16 '22 16:10

sorjef