Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#18] AWS: Cloudfront configuration #22

Merged
merged 91 commits into from
Jun 30, 2023

Conversation

cld-vasconcelos
Copy link
Collaborator

@cld-vasconcelos cld-vasconcelos commented Jun 12, 2023

Setup Cloudfront so that it can connect to both S3 Bucket hosting the static website and/or the application load balancer:

aws-cloudfront

Before this change Cloudfront was only connecting to the S3 Bucket, forcing to access to the application load balancer directly or through its Route 53 entry (removed in this PR)

@cld-vasconcelos cld-vasconcelos self-assigned this Jun 12, 2023
@cld-vasconcelos cld-vasconcelos changed the base branch from aws-bastion-host to cv/17/aws-key-management June 12, 2023 08:26
Base automatically changed from cv/17/aws-key-management to main June 22, 2023 10:38
Comment on lines 99 to 122
# -----------------------------------------------------------------------------
# AWS autoscaling group
# -----------------------------------------------------------------------------
resource "aws_autoscaling_group" "bastion" {
name = "${var.solution_name}-bastion"

desired_capacity = 1
max_size = 1
min_size = 1

vpc_zone_identifier = var.subnets_ids

launch_template {
id = aws_launch_template.bastion.id
version = aws_launch_template.bastion.latest_version
}

instance_refresh {
strategy = "Rolling"
preferences {
min_healthy_percentage = 50
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need an autoscaling group if it's just 1 instance? Is it for auto recovery in case of a crash?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is for availability purposes.

actions = ["s3:GetObject"]
resources = ["${module.static_website_bucket.bucket.arn}/*"]
actions = ["s3:*"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change from GetObject to * ? Shouldn't Cloudfront only read the bucket?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two S3 buckets: One for the static website and other for Cloudfront to write logs. This policy is for the latter, while the policy for the former is in ´modules/aws/data.tf´ and only allows reading from it.

@@ -1,66 +1,142 @@
resource "aws_cloudfront_origin_access_identity" "origin_access_identity" {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need an id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 13 to 18
secret_string = <<EOF
{
"username": "${aws_db_instance.instance[count.index].username}",
"password": "${aws_db_instance.instance[count.index].password}"
}
EOF

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

@cld-vasconcelos cld-vasconcelos merged commit 455c28e into main Jun 30, 2023
@cld-vasconcelos cld-vasconcelos deleted the cv/18/cloudfront-configuration branch June 30, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants