diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 8ddfa4d..cffd5fa 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -9,6 +9,9 @@ permissions: id-token: write contents: read +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + concurrency: group: development-deployment cancel-in-progress: true @@ -24,9 +27,11 @@ jobs: working-directory: . steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v5 - - uses: actions/setup-node@v4 + - name: Setup Node.js + uses: actions/setup-node@v5 with: node-version: 22 cache: npm @@ -45,7 +50,7 @@ jobs: echo "Environment: dev" - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@v5 with: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} aws-region: us-east-1 diff --git a/.gitignore b/.gitignore index dc93deb..5c836a9 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,7 @@ crash.*.log # Exclude all .tfvars files, which are likely to contain sensitive data *.tfvars *.tfvars.json -.tfvars* +.tfvars # Ignore override files override.tf diff --git a/README.md b/README.md index a760d6a..6e100c0 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ This system provisions and connects: --- -## 📁 Project Structure (Typical) +## 📁 Project Structure ``` . @@ -50,9 +50,9 @@ This system provisions and connects: ├── index.html # Vite entry HTML file ├── package.json + other configs # Project dependencies and scripts │ -├── terraform/ # Infrastructure as Code (Terraform) +├── terraform/ # Infrastructure as Code (Terraform) directory │ │ -│ ├── bootstrap/ # One-time setup (state backend, foundational resources) +│ ├── bootstrap/ # One-time setup (state backend, foundational resource) │ │ │ ├── modules/ # Reusable Terraform modules │ │ │ @@ -88,7 +88,6 @@ This project was built with: - Reusable Terraform modules for multi-project usage - Production-ready S3 security configuration - Clean separation of infrastructure and frontend build -- Remote state backend with state locking --- @@ -265,16 +264,32 @@ Just change: - S3 bucket is private by default - CloudFront serves as the only public entry point - IAM follows least privilege principle -- GitHub Actions uses short-lived credentials (OIDC) -- No hardcoded secrets in repo --- -## 📈 Lessons Learned +## 🧱 Infrastructure Teardown -- Add custom domain + Route53 automation -- ACM SSL certificate provisioning -- Automated performance testing in CI +1. From each environment directory (dev, staging and prod), run the command: + +``` +terraform destroy -auto-approve +``` + +Do this for all environments. + +2. From the terraform **_bootstrap_** directory, run the command: + +``` +terraform destroy -auto-approve + +``` + +3. Optional, but can do: List all AWS buckets in your account and confirmbuckets are not listed. Run the command: + +``` +aws s3 ls + +``` --- @@ -387,6 +402,12 @@ Writing reusable setup instructions and architecture explanations can improve: --- -## 👨‍💻 Author +## 📈 Future Improvements + +- Add custom domain + Route53 automation +- ACM SSL certificate provisioning +- Automated performance testing in CI -Built and Maintained by [ecoderP](https://github.com/ecoderP) +--- + +## 👨‍💻 Author diff --git a/terraform/bootstrap/terraform.tfvarsexample b/terraform/bootstrap/terraform.tfvarsexample new file mode 100644 index 0000000..0bb43c2 --- /dev/null +++ b/terraform/bootstrap/terraform.tfvarsexample @@ -0,0 +1,4 @@ +aws_region = "Your AWS region" +project_name = "Your project name" +backend_bucket_name = "Your unique bucket name" +s3_encryption_algorithm = "AES256" # Default to SSE-S3 diff --git a/terraform/environments/dev/dev.tfbackendexample b/terraform/environments/dev/dev.tfbackendexample new file mode 100644 index 0000000..3d94a31 --- /dev/null +++ b/terraform/environments/dev/dev.tfbackendexample @@ -0,0 +1,5 @@ +bucket = "Your bootstrap backend state bucket name" +region = "Your AWS region" +key = "dev/terraform.tfstate" +encrypt = true +use_lockfile = true # important for S3 backend state lock \ No newline at end of file diff --git a/terraform/environments/dev/terraform.tfvarsexample b/terraform/environments/dev/terraform.tfvarsexample new file mode 100644 index 0000000..836681f --- /dev/null +++ b/terraform/environments/dev/terraform.tfvarsexample @@ -0,0 +1,6 @@ +aws_region = "Your AWS region" +project_name = "Project name" +website_bucket_name = "Your unique bucket name" # unique for each environment +github_repo = "Your-github-username/repo-name" # Not web link +github_branch = "dev" +environment = "dev" diff --git a/terraform/environments/prod/prod.tfbackendexample b/terraform/environments/prod/prod.tfbackendexample new file mode 100644 index 0000000..93dbd39 --- /dev/null +++ b/terraform/environments/prod/prod.tfbackendexample @@ -0,0 +1,5 @@ +bucket = "Your bootstrap backend state bucket name" +region = "Your AWS region" +key = "prod/terraform.tfstate" +encrypt = true +use_lockfile = true # important for S3 backend state lock \ No newline at end of file diff --git a/terraform/environments/prod/terraform.tfvarsexample b/terraform/environments/prod/terraform.tfvarsexample new file mode 100644 index 0000000..027ad41 --- /dev/null +++ b/terraform/environments/prod/terraform.tfvarsexample @@ -0,0 +1,6 @@ +aws_region = "Your AWS region" +project_name = "Project name" +website_bucket_name = "Your unique bucket name" +github_repo = "Your github username/repo name" # Not web link +github_branch = "prod" +environment = "prod" diff --git a/terraform/environments/staging/staging.tfbackendexample b/terraform/environments/staging/staging.tfbackendexample new file mode 100644 index 0000000..fb4c21e --- /dev/null +++ b/terraform/environments/staging/staging.tfbackendexample @@ -0,0 +1,5 @@ +bucket = "Your bootstrap backend state bucket name" +region = "Your AWS region" +key = "staging/terraform.tfstate" +encrypt = true +use_lockfile = true # important for S3 backend state lock \ No newline at end of file diff --git a/terraform/environments/staging/terraform.tfvarsexample b/terraform/environments/staging/terraform.tfvarsexample new file mode 100644 index 0000000..361647c --- /dev/null +++ b/terraform/environments/staging/terraform.tfvarsexample @@ -0,0 +1,6 @@ +aws_region = "Your AWS region" +project_name = "Project name" +website_bucket_name = "Your unique bucket name" # unique for each environment +github_repo = "Your github username/repo name" # Not web link +github_branch = "staging" +environment = "staging"