CodeDeploy CI/CD (EC2 / ECS / Lambda)
CodeDeploy application, deployment groups, and the platform-correct service role for automated EC2/ECS/Lambda rollouts with auto-rollback on failure.
Verification
Static-verifiedPassed: validated and lint-clean (provider-schema-validated for AWS/Azure/GCP; Terraform-language lint elsewhere).
Conformance
- Static validation (fmt · validate · tflint)
- Security scan clean (Checkov)
- Plan tests (mocked: validation rules · outputs)
Provenance
- SHA-256 checksum
- Signature (pending)
Functional
- Live test pending (no cloud run yet)
Last verified 2026-06-28 · how we verify
Documentation
aws-codedeploy
An AWS CodeDeploy application with deployment groups for CI/CD rollouts to EC2/on-premises (Server), ECS, or Lambda — plus the correctly-scoped service role, created automatically. CodeDeploy itself is free for EC2/Lambda/ECS deployments.
Status: static-validated, live-test pending. Validated with
tofu validate
tflint+checkov(STATIC_OK). A live test was attempted against a real account: the IAM service role applies correctly, butCreateApplicationreturnedSubscriptionRequiredExceptionbecause that sandbox account is not activated for CodeDeploy — an account/billing state, not a module defect. Ready to live-test on any CodeDeploy-enabled account viatests/live.tfvars.
Design & secure defaults
- Platform-correct service role. The module attaches the right AWS-managed
policy for the chosen
compute_platform(AWSCodeDeployRolefor Server,AWSCodeDeployRoleForECSfor ECS,AWSCodeDeployRoleForLambdafor Lambda) — the usual cause of "deployment failed" misconfigurations. Bring your own role withcreate_service_role = false+service_role_arn. - Automatic rollback on failure is on by default for every deployment group
(
auto_rollback_configurationwithDEPLOYMENT_FAILURE). - Sensible deployment config per platform (
OneAtATime/ECSAllAtOnce/LambdaAllAtOnce) unless you overridedeployment_config_name. - Preconditions enforce platform invariants (ECS requires
ecs_service; a BYO role requiresservice_role_arn).
Usage
module "codedeploy" {
source = "github.com/ITfreak/iacbazaar//artifacts/terraform/aws-codedeploy"
name = "web-app"
compute_platform = "Server"
deployment_groups = {
production = {
ec2_tag_filters = [{ key = "App", value = "web" }]
}
}
}
ECS blue/green example:
module "codedeploy" {
source = "github.com/ITfreak/iacbazaar//artifacts/terraform/aws-codedeploy"
name = "orders"
compute_platform = "ECS"
deployment_groups = {
prod = {
deployment_type = "BLUE_GREEN"
ecs_service = { cluster_name = "orders", service_name = "orders-api" }
}
}
}
See examples/basic for a complete configuration.
Key inputs
| Variable | Description | Default |
|---|---|---|
name | Application name + resource prefix | required |
compute_platform | Server / ECS / Lambda | Server |
create_service_role / service_role_arn | Create the service role, or supply one | true / null |
deployment_groups | Map of deployment groups (targeting, style, rollback, alarms, triggers) | {} |
tags | Tags for all resources | {} |
Each deployment group supports: deployment_config_name, auto_rollback(+events),
ec2_tag_filters / autoscaling_groups (Server), ecs_service (ECS),
deployment_type (IN_PLACE/BLUE_GREEN), deployment_option, alarms, and an
SNS trigger.
Outputs
application_name, application_id, compute_platform, service_role_arn,
service_role_name, deployment_group_names, deployment_group_ids (map).
Provider
hashicorp/aws >= 6.0, < 7.0. Requires Terraform/OpenTofu >= 1.6.
License
Commercial — LicenseRef-IaCBazaar-Commercial. See the IaC Bazaar terms.