Deploy Terraform ... with Terraform.
terraform-aws-pipeline
Deploy Terraform with Terraform.🐓 🥚 ?
(If you want to deploy to multiple AWS accounts use terraform-multi-account-pipeline)
Prerequisites
- An existing AWS CodeCommit repository OR an AWS CodeConnection connection to the third-party source and repo of your choice (GitHub, Gitlab, etc)
- Remote state that the pipeline can access (using the CodeBuild IAM role)
Module Inputs
AWS Codecommit:
module "pipeline" { source = "aws-samples/pipeline/aws" version = "2.4.x" pipeline_name = "pipeline-name" repo = "codecommit-repo-name" } If you are using CodeCommit, the module must be deployed to a separate repository to the code that you want to push through it. See codecommit deployment
Third-party service:
module "pipeline" { source = "aws-samples/pipeline/aws" version = "2.4.x" pipeline_name = "pipeline-name" repo = "organization/repo" connection = awscodestarconnectionsconnection.this.arn } pipeline_name is used to name the pipeline and prefix other resources created, like IAM roles.
repo is the name of your existing repo that the pipeline will use as a source. If you are using a third-party service, the format is "my-organization/repo"
connection is the connection arn of the connection to the third-party repo.
Optional Inputs
module "pipeline" {
...
branch = "main"
mode = "SUPERSEDED"
detect_changes = false
kmskey = awskms_key.this.arn
accessloggingbucket = awss3bucket.this.id
artifact_retention = 90
log_retention = 90
codebuildpolicy = awsiam_policy.this.arn build_timeout = 10 terraform_version = "1.8.0" checkov_version = "3.2.0" tflint_version = "0.55.0"
build_override = { directory = "terraform" planbuildspec = file("./myplan.yml") planimage = "aws/codebuild/amazonlinux2-x8664-standard:5.0" applybuildspec = file("./myapply.yml") apply_image = "hashicorp/terraform:latest" }
vpc = { vpc_id = "vpc-011a22334455bb66c", subnets = ["subnet-011aabbcc2233d4ef"], securitygroupids = ["sg-001abcd2233ee4455"], }
notifications = { snstopic = awssns_topic.this.arn detail_type = "BASIC" events = [ "codepipeline-pipeline-pipeline-execution-failed", "codepipeline-pipeline-pipeline-execution-succeeded" ] } tags = join(",", [ "Environment[Dev,Prod]", "Source" ]) tagnag_version = "0.7.9"
checkov_skip = [ "CKVAWS144", #Ensure that S3 bucket has cross-region replication enabled ] }
See optional inputs for descriptions.
Docs
Related Resources
Security
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.