Skip to content

Making Deploy Stage Optional #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

Conversation

pcartas
Copy link
Contributor

@pcartas pcartas commented Jul 24, 2023

what

I create a new variable called deploy_stage_enabled, and then make dynamic the deploy stage of aws_codepipeline bitbucket and aws_codepipeline default

why

It allows you to create images without deploying them, which could be useful for creating dummy images. However, there's a catch-22 situation: when you create a service, you need an initial image that at least responds to the health path. But first, you need to run a pipeline, and the pipeline is not created before the service. Moreover, ECS (specially if you are using EC2) tends to cache images/references to those images, and if you always use the image with the 'latest' tag, you risk using an old image. To avoid this, it's good practice to tag your image twice (with 'latest' and a random tag). The idea behind this was to create a dummy image, pull it from my service module, and then push it with the correct tags to the ECR of the service (thereby making it the base image of the service). Then I would define my container as follows:

data "aws_ecr_image" "service_image" {
  repository_name = module.ecr.repository_name
  image_tag       = "${var.environment}-latest"

  depends_on = [
    module.ecr
  ]
}

module "container_definition" {
  source                       = "cloudposse/ecs-container-definition/aws"
  version                      = "0.58.1"
  container_name               = var.container_name
  container_image              = "${var.aws_account_id}.dkr.ecr.${var.region}.amazonaws.com/${var.project_name}:${data.aws_ecr_image.service_image.image_tags[1]}"
  #container_image              = "${var.aws_account_id}.dkr.ecr.${var.region}.amazonaws.com/${var.project_name}:${var.environment}-latest"
  container_memory             = var.container_memory
  container_memory_reservation = var.container_memory_reservation
  docker_security_options      = var.docker_security_options
  container_cpu                = var.container_cpu
  essential                    = var.container_essential
  readonly_root_filesystem     = var.container_readonly_root_filesystem
  environment                  = var.task_environment_variables
  secrets                      = var.task_environment_secret_variables
  port_mappings                = var.container_port_mappings
  log_configuration            = {
                                  "logDriver": "awslogs",
                                  "options": {
                                      "awslogs-group": "/ecs/${var.container_name}",
                                      "awslogs-region": "${var.region}",
                                      "awslogs-create-group": "true",
                                      "awslogs-stream-prefix": "ecs"
                                  }
                                  secretOptions = []
                                }
  depends_on = [
    module.ecr
  ]
}

@pcartas pcartas requested review from a team as code owners July 24, 2023 14:53
@pcartas pcartas requested review from srhopkins and joe-niland July 24, 2023 14:53
@hans-d
Copy link

hans-d commented Mar 2, 2024

/terratest

@hans-d hans-d added the stale This PR has gone stale label Mar 2, 2024
@hans-d
Copy link

hans-d commented Mar 3, 2024

@pcartas Hi, can you update the pr so that it passes the tests? otherwise, it is likely to be closed due to staleness.

@mergify mergify bot added triage Needs triage and removed stale This PR has gone stale labels Apr 1, 2024
Copy link

mergify bot commented May 29, 2025

💥 This pull request now has conflicts. Could you fix it @pcartas? 🙏

@mergify mergify bot added the conflict This PR has conflicts label May 29, 2025
@mergify mergify bot closed this May 29, 2025
Copy link

mergify bot commented May 29, 2025

This PR was closed due to inactivity and merge conflicts. 😭
Please resolve the conflicts and reopen if necessary.

Copy link

coderabbitai bot commented May 29, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

A new boolean input, deploy_stage_enabled, was introduced to control the inclusion of the deploy stage in the pipeline. The ECS cluster and service name inputs were made optional, with default empty strings and updated descriptions. Resource definitions and example configurations were updated to support conditional deployment stage inclusion based on this flag.

Changes

Files Change Summary
variables.tf, docs/terraform.md Added deploy_stage_enabled variable/input; made ecs_cluster_name and service_name optional with defaults.
main.tf Converted static "Deploy" stage blocks to dynamic blocks, conditionally included based on deploy_stage_enabled.
examples/complete/variables.tf Added deploy_stage_enabled variable with default true and description.
examples/complete/main.tf Passed deploy_stage_enabled variable to ecs_codepipeline module.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a674ef and 695fe97.

⛔ Files ignored due to path filters (1)
  • README.md is excluded by !README.md
📒 Files selected for processing (5)
  • docs/terraform.md (2 hunks)
  • examples/complete/main.tf (1 hunks)
  • examples/complete/variables.tf (1 hunks)
  • main.tf (2 hunks)
  • variables.tf (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mergify mergify bot removed conflict This PR has conflicts triage Needs triage labels May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants