Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ Just change:
- S3 bucket is private by default
- CloudFront serves as the only public entry point
- IAM follows least privilege principle
- In in _main.tf_ file inside _terraform/bootstrap_,

```
lifecycle {
prevent_destroy = false
}
```

is set to _false_ for easy clean-up. In real production environments, I would set _prevent_destroy_ as _true_. This protects the remote state bucket from accidental data loss.

In addition,

```
force_destroy = true
```

should be deleted or set as _false_ in real production environments.

---

Expand Down Expand Up @@ -406,6 +423,7 @@ Writing reusable setup instructions and architecture explanations can improve:

- Add custom domain + Route53 automation
- ACM SSL certificate provisioning
- Integrate terraform into CI/CD pipeline
- Automated performance testing in CI

---
Expand Down
4 changes: 3 additions & 1 deletion terraform/bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ resource "aws_s3_bucket" "terraform_state" {
bucket = "${var.project_name}-${var.backend_bucket_name}-${random_id.suffix.hex}"

lifecycle {
prevent_destroy = true
prevent_destroy = false
}

force_destroy = true

tags = {
Name = "${var.project_name}-terraform-backend"
Environment = "Shared"
Expand Down
2 changes: 1 addition & 1 deletion terraform/bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ variable "project_name" {
variable "s3_encryption_algorithm" {
description = "Encryption algorithm for S3 buckets"
type = string
}
}
2 changes: 2 additions & 0 deletions terraform/modules/s3-static-site/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
resource "aws_s3_bucket" "site_bucket" {
bucket = var.bucket_name

force_destroy = true

tags = {
Name = var.bucket_name
Environment = var.environment
Expand Down
Loading