Skip to main content

Posts

Showing posts with the label Terraform

Fixing 'bad CPU type in executable' on macOS for AWS CLI and Terraform

  You provision a new Apple M-series Mac, restore your shell profile, clone your infrastructure repository, and run   terraform plan   or   aws sts get-caller-identity . Instead of the expected output, your terminal immediately halts with:   zsh: bad CPU type in executable . This error halts productivity for Cloud Engineers and system administrators migrating to modern Apple hardware. It indicates a fundamental architecture mismatch between your installed command-line tools and the host operating system. Here is exactly why this happens and the definitive steps to resolve it permanently. Understanding the Root Cause: Architecture Mismatch To understand the  bad CPU type in executable macOS  error, you must look at the underlying CPU architecture. Legacy Mac hardware utilized Intel processors, which are built on the  x86_64  (or AMD64) instruction set. Modern Apple Silicon (M1, M2, M3, M4) utilizes the  ARM64  (or  aarch64 ) ins...

Refactoring Terraform Modules: Using "moved" Blocks to Avoid Destroy/Create

  Every Senior DevOps engineer has experienced the specific panic induced by a Terraform plan output showing   1 to destroy, 1 to add   on a stateful resource. You simply wanted to rename a resource variable for consistency or move a spaghetti-code   main.tf   resource into a reusable child module. However, Terraform interprets this change not as a migration, but as the deletion of the old resource and the provisioning of a new one. For stateless EC2 instances in an Auto Scaling Group, this is an inconvenience. For an RDS instance, an S3 bucket, or a production Load Balancer with hardcoded DNS pointers, this is catastrophic. Historically, the solution was the imperative  terraform state mv  command. This approach is brittle, manual, effectively invisible to code review, and breaks CI/CD automation. Since Terraform 1.1, the declarative  moved  block is the standard for solving this problem safely. The Root Cause: State Identity vs. Configurati...