Add modern IaC examples: Terraform, Packer, cloud-config, and CI/CD#1
Merged
Add modern IaC examples: Terraform, Packer, cloud-config, and CI/CD#1
Conversation
Analyses the 2012 cloud-init-sample repo and provides a comprehensive modernization path covering every layer of the original architecture: - MODERNIZATION.md: Full analysis mapping 2012 concepts to modern equivalents, migration phases, and tool reference table - modern/terraform/: Declarative Terraform replacing create_instance.sh - aws_autoscaling_group + aws_launch_template (replaces run-instances loop) - Dynamic AMI data source (replaces hardcoded ami-28e07e50 / RHEL 7) - IAM Instance Profile + SSM access (replaces SSH key pairs + port 22) - t3.micro replacing t2.micro, Amazon Linux 2023 replacing RHEL 7 EOL - modern/cloud-config/: YAML cloud-config replacing bash user-data scripts - Declarative users/groups/packages/write_files modules - Templatefile version (Terraform-rendered) + standalone version - cloud-init schema-validatable - modern/packer/: Pre-baked AMI pipeline - Installs software at AMI build time (not instance boot time) - Immutable infrastructure pattern: AMI is the versioned artifact - modern/.github/workflows/: CI/CD pipeline replacing manual script execution - deploy.yml: Plan on PR, Apply on merge (with approval gate), Destroy on demand - packer-build.yml: Rebuild AMI when packer/ansible config changes - OIDC auth to AWS (no stored credentials) https://claude.ai/code/session_011yTw5W74dhGvxs4GxEcKFq
Publishable article series covering the evolution from 2012-era shell script provisioning to modern IaC: - Part 1: Origin story — what the repo got right (cattle pattern, config-as-code, decoupled orchestration) - Part 2: The gap — what aged poorly (hardcoded AMI, bash user-data, SSH/port-22, no state, runtime downloads, no CI/CD) - Part 3: The modern rebuild — Terraform, cloud-config YAML, SSM Session Manager, Packer, GitHub Actions with OIDC Each part references the actual code in the repo (original and /modern). https://claude.ai/code/session_011yTw5W74dhGvxs4GxEcKFq
Adds .github/workflows/deploy.yml with: - Validate job: terraform fmt check + cloud-config YAML schema validation - Plan job: OIDC auth, terraform plan on every PR with output posted as PR comment - Build AMI job: Packer build on merge to main - Apply job: terraform apply with manual approval gate via GitHub Environments Uses OIDC federated identity (no stored AWS credentials) and path filters to only trigger on changes to modern/terraform, modern/cloud-config, or modern/packer. https://claude.ai/code/session_011yTw5W74dhGvxs4GxEcKFq
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a comprehensive modernization guide and working examples showing how the original 2012 cloud-init/Chef/Ansible patterns map to current Infrastructure as Code best practices. Includes production-ready Terraform configurations, Packer AMI building, cloud-config YAML templates, and GitHub Actions CI/CD pipelines.
Key Changes
Documentation
Terraform Infrastructure as Code
main.tf: Declarative infrastructure replacing
create_instance.sh:variables.tf: Parameterized inputs replacing positional bash arguments
outputs.tf: Useful post-apply information (ASM name, AMI ID, SSM connection commands)
Cloud-Config YAML
cloud-config.yaml: Terraform templatefile version with variable substitution:
cloud-config-standalone.yaml: Standalone version for direct AWS CLI use
Packer AMI Building
GitHub Actions CI/CD
deploy.yml: Complete infrastructure pipeline:
packer-build.yml: AMI building pipeline:
Supporting Files
Notable Implementation Details
terraform destroyreplaces manualterminate_instances.sh.https://claude.ai/code/session_011yTw5W74dhGvxs4GxEcKFq