This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_autoscaling_group" "worker" { | |
# Force a redeployment when launch configuration changes. | |
# This will reset the desired capacity if it was changed due to | |
# autoscaling events. | |
name = "${aws_launch_configuration.worker.name}-asg" | |
min_size = 10 | |
desired_capacity = 15 | |
max_size = 25 | |
health_check_type = "EC2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_launch_configuration" "worker" { | |
# Launch Configurations cannot be updated after creation with the AWS API. | |
# In order to update a Launch Configuration, Terraform will destroy the | |
# existing resource and create a replacement. | |
# | |
# We're only setting the name_prefix here, | |
# Terraform will add a random string at the end to keep it unique. | |
name_prefix = "worker-" | |
image_id = "${data.aws_ami.amazon_linux.id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: Boxstarter Script | |
# Author: Jess Frazelle <[email protected]> | |
# Last Updated: 2017-09-11 | |
# | |
# Install boxstarter: | |
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force | |
# | |
# You might need to set: Set-ExecutionPolicy RemoteSigned | |
# | |
# Run this boxstarter by calling the following from an **elevated** command-prompt: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Resources: | |
VPC: | |
Type: "AWS::EC2::VPC" | |
Properties: | |
CidrBlock: 10.0.0.0/16 | |
SecurityGroup: | |
Type: "AWS::EC2::SecurityGroup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_ecs_service" "web" { | |
# Do not reset desired count if it was changed due to autoscaling | |
lifecycle { | |
ignore_changes = ["desired_count"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the current ACTIVE revision in ECS task family | |
data "aws_ecs_task_definition" "web" { | |
task_definition = "${module.web.ecs_task_family}" | |
} | |
resource "aws_ecs_service" "web" { | |
# Use the latest task revision - either the existing one, or the newly created | |
# if the task was updated. | |
task_definition = "${max("${aws_ecs_task_definition.web.revision}", "${var.ecs_task_current_revision}")}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task_variables { | |
app = "${var.app_name}" | |
image = "${module.ecr.repository_url}:${lookup(data.external.active_image_versions.result, var.app_name, "latest")}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use current image versions to avoid surreptitious app deployments | |
data "external" "active_image_versions" { | |
program = ["python", "/scripts/get_image_tags.py"] | |
query = { | |
cluster_name = "${data.terraform_remote_state.ecs.ecs_cluster_id}" | |
service_name = "${var.app_name}" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# some env vars here | |
STARTED_BY="$(date +"%T") - $USERNAME" | |
AWS_DEFAULT_REGION="${REGION}" | |
TASK_ID="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
infraPipeline() |
NewerOlder