Giter Site home page Giter Site logo

kintex98 / terraform-aws-automation-solutions Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

HCL workflows which will deploy AWS resources through Terraform to automate tasks

License: MIT License

HCL 75.86% PowerShell 24.14%
cloud-solutions devops infrastructure-as-code terraform cloud-automation

terraform-aws-automation-solutions's Introduction

terraform-aws-automation-solutions

HCL workflows which will deploy AWS resources through Terraform to automate tasks

Introduction

The goal of this repository is to provide solutions for key AWS automation needs and/or Terraform dynamic coding challenges. I will try to keep the cost, dependencies, deployed resources, and maintenance succinct in that general order of importance. I may discuss ways in which you can further expand on the automation and I may also provide those solutions if asked.

aws-codedeploy-zips

Used to dynamically define and generate codedeploy zip files en masse. For every directory under [aws-codedeploy-zips/codedeploy](aws-codedeploy-zips/codedeploy, we will generate a zip file whose contents are all the files under that directory with its terraform variable calls filled out.

Depends On

  • S3 Bucket - Any bucket will do. Needed to store the codedeploy zip files

aws-stig-hardened-amis

Used to dynamically deploy "n" amis where "n" = # of objects defined in var.ami_specs

Depends On

  • VPC - Default VPC should exist, though not recommended
  • Security Group - Default SG should exist, though not recommended

Deploys

  • IAM Role - EC2ImageBuilderInstanceRole
  • Image Builder Pipeline - <parent_image>-pipeline*n
    • Image Builder Recipe - <parent_image>-recipe*n
    • Image Builder Infrastructure Configuration - <parent_image>-infra-config*n
    • Image Builder Distribution Configuration - <parent_image>-distrib-config*n

STIG Component Naming Scheme

stig-build-<platform>-<severity>
e.g. stig-build-windows-medium
Severity Platform
low linux
medium windows
high

Parent Image Naming Scheme

<base platform>-<type>-<CPU architecture>
e.g. windows-server-2019-english-full-sql-2019-enterprise-x86 or amazon-linux-2023-ecs-optimized-arm64
Base Name Type CPU Architecture
amazon-linux-2 ecs-optimized x86
amazon-linux-2023 ecs-optimized-kernel-5 arm64
windows-server-2016 english-full-base
windows-server-2019 english-full-sql-2019-enterprise
windows-server 2022 english-core-base

Expanding the Automation

Exact AMI Build Invocation

If all you care about are AWS AMIs, then for a small/non-existent uptick in costs, you can build about the latest AMI immediately rather than utilizing Image Builder cron jobs/image publishing schedule (which lags 0-4 days behind the AMI release schedule).

  1. Create an EventBridge rule which can trigger the Image Builder Pipeline

  2. Create a Lambda function which PutEvents when triggered

  3. Create a SNS Subscription to one of these SNS Topics and to invoke the lambda function

    Platform Topic ARN
    Windows "arn:aws:sns:us-east-1:801119661308:ec2-windows-ami-update"
    Amazon Linux 2 "arn:aws:sns:us-east-1:137112412989:amazon-linux-2-ami-updates"
    Amazon Linux 2023 "arn:aws:sns:us-east-1:137112412989:amazon-linux-2023-ami-updates"

Clean Up Old AMIs

Amazon deprecates their AMIs every 4 build cycles. This is a good habit to have as it'll clean up used EBS storage, remove clutter from AMI list and prevent careless mistakes from using an old AMI.

  1. EventBridge rule triggers on Image Builder completion
  2. Sends event to Lambda function which will parse for name of <parent_image> in pipeline finished event
  3. If pipeline images >4, Lambda will deregister the oldest AMI, delete its snapshot, and delete the corresponding Image Builder Image version.

terraform-aws-automation-solutions's People

Contributors

kintex98 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.