-
Notifications
You must be signed in to change notification settings - Fork 2
PLT-9274 - Atlantis EC2 instance and subsequent infrastructure to support it. #121
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe recent changes in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
atlantis plan |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
atlantis apply -d infra/us-east-1/mgmt/atlantis/ecr |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 3
Configuration used: CodeRabbit UI
Files selected for processing (3)
- infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl (1 hunks)
- infra/us-east-1/mgmt/atlantis/ecr/terragrunt.hcl (1 hunks)
- infra/us-east-1/mgmt/atlantis/security-group/terragrunt.hcl (1 hunks)
Additional comments: 8
infra/us-east-1/mgmt/atlantis/security-group/terragrunt.hcl (3)
- 1-13: The
locals
block is well-structured, providing a clear hierarchy and reuse of variables. It's good to see the use offind_in_parent_folders
to keep the configuration DRY.- 15-17: The
terraform
block specifies the source of the security group module. Ensure that the referenced versionv5.1.0
of theterraform-aws-security-group
module is compatible with the rest of the infrastructure and Terraform version in use.- 24-26: The
dependency
block for the VPC is correctly set up to reference the VPC configuration. However, ensure that the VPC configuration is applied and has the necessary outputs, especiallyvpc_id
, which is used in the inputs block.infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl (2)
- 1-12: The
locals
block is well-structured and follows the same pattern as the security-group configuration, which is good for consistency across modules.- 14-16: The
terraform
block specifies the source of the EC2 instance module. Ensure that the referenced versionv5.6.0
of theterraform-aws-ec2-instance
module is compatible with the Terraform version in use.infra/us-east-1/mgmt/atlantis/ecr/terragrunt.hcl (3)
- 1-39: The
locals
block is consistent with the other modules, and the lifecycle policy is well-defined with clear rules for managing the ECR repository images.- 41-43: The
terraform
block specifies the source of the ECR module. Ensure that the referenced versionv1.6.0
of theterraform-aws-ecr
module is compatible with the Terraform version in use.- 45-48: The
inputs
block correctly sets up the ECR repository with a lifecycle policy. Ensure that therepository_name
is unique and follows any naming conventions that may be in place.
inputs = { | ||
vpc_id = dependency.vpc.outputs.vpc_id | ||
|
||
computed_ingress_cidr_blocks = ["0.0.0.0/0"] | ||
ingress_cidr_blocks = ["0.0.0.0/0"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inputs
block defines ingress rules with CIDR blocks set to 0.0.0.0/0
, which allows unrestricted access. This is a potential security risk. Recommend restricting the ingress to only necessary IP ranges.
- computed_ingress_cidr_blocks = ["0.0.0.0/0"]
- ingress_cidr_blocks = ["0.0.0.0/0"]
+ computed_ingress_cidr_blocks = ["<restricted-ip-range>"]
+ ingress_cidr_blocks = ["<restricted-ip-range>"]
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
inputs = { | |
vpc_id = dependency.vpc.outputs.vpc_id | |
computed_ingress_cidr_blocks = ["0.0.0.0/0"] | |
ingress_cidr_blocks = ["0.0.0.0/0"] | |
} | |
inputs = { | |
vpc_id = dependency.vpc.outputs.vpc_id | |
computed_ingress_cidr_blocks = ["<restricted-ip-range>"] | |
ingress_cidr_blocks = ["<restricted-ip-range>"] | |
} |
dependency "security_group" { | ||
config_path = "../security-group" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verification process has consistently shown that there is no output for security_group_id
in the terragrunt.hcl
file within the security group configuration directory. This suggests that the review comment is correct in stating that the security group configuration needs to have the necessary outputs, especially security_group_id
, which is not currently present.
Analysis chain
The dependency
block for the security group is correctly set up. Ensure that the security group configuration is applied and has the necessary outputs, especially security_group_id
, which is used in the inputs block.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify that the security group configuration has been applied and outputs the necessary security_group_id.
rg --type hcl 'output "security_group_id"' infra/us-east-1/mgmt/atlantis/security-group
Length of output: 117
Script:
#!/bin/bash
# Verify that the security group configuration has the necessary output "security_group_id".
rg 'output "security_group_id"' infra/us-east-1/mgmt/atlantis/security-group
Length of output: 78
Script:
#!/bin/bash
# List all HCL files in the security group configuration directory to ensure we are not missing any files.
fd '\.hcl$' infra/us-east-1/mgmt/atlantis/security-group
Length of output: 118
Script:
#!/bin/bash
# Check the contents of the terragrunt.hcl file in the security group configuration directory for the output "security_group_id".
cat infra/us-east-1/mgmt/atlantis/security-group/terragrunt.hcl | rg 'output "security_group_id"'
Length of output: 99
inputs = { | ||
name = local.name | ||
instance_type = "t2.micro" | ||
|
||
|
||
create_iam_instance_profile = true | ||
iam_role_description = "IAM role for EC2 instance" | ||
iam_role_policies = { | ||
AdministratorAccess = "arn:aws:iam::aws:policy/AdministratorAccess" | ||
} | ||
|
||
subnet_id = dependency.vpc.outputs.public_subnets[0] | ||
|
||
vpc_security_group_ids = [dependency.security_group.outputs.security_group_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inputs
block sets up the EC2 instance with a t2.micro
instance type and an IAM role with AdministratorAccess
. This is a potential security risk as it grants broad permissions to the EC2 instance. Recommend using a least privilege role specific to the instance's needs.
- AdministratorAccess = "arn:aws:iam::aws:policy/AdministratorAccess"
+ # Replace with a policy that follows the principle of least privilege
+ CustomLimitedAccess = "arn:aws:iam::aws:policy/CustomLimitedAccessPolicy"
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
inputs = { | |
name = local.name | |
instance_type = "t2.micro" | |
create_iam_instance_profile = true | |
iam_role_description = "IAM role for EC2 instance" | |
iam_role_policies = { | |
AdministratorAccess = "arn:aws:iam::aws:policy/AdministratorAccess" | |
} | |
subnet_id = dependency.vpc.outputs.public_subnets[0] | |
vpc_security_group_ids = [dependency.security_group.outputs.security_group_id] | |
inputs = { | |
name = local.name | |
instance_type = "t2.micro" | |
create_iam_instance_profile = true | |
iam_role_description = "IAM role for EC2 instance" | |
iam_role_policies = { | |
# Replace with a policy that follows the principle of least privilege | |
CustomLimitedAccess = "arn:aws:iam::aws:policy/CustomLimitedAccessPolicy" | |
} | |
subnet_id = dependency.vpc.outputs.public_subnets[0] | |
vpc_security_group_ids = [dependency.security_group.outputs.security_group_id] |
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
atlantis apply |
This comment has been minimized.
This comment has been minimized.
atlantis unlock |
This comment has been minimized.
This comment has been minimized.
atlantis plan |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- infra/us-east-1/mgmt/atlantis/ec2/terragrunt.hcl
atlantis apply -d infra/us-east-1/mgmt/atlantis/ec2 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
atlantis apply -d infra/us-east-1/mgmt/atlantis/ec2 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
atlantis unlock |
Failed to delete PR locks |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
atlantis apply -d infra/us-east-1/mgmt/atlantis/alb |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- infra/us-east-1/mgmt/atlantis/alb/terragrunt.hcl (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- infra/us-east-1/mgmt/atlantis/alb/terragrunt.hcl
This comment has been minimized.
This comment has been minimized.
atlantis plan |
This comment has been minimized.
This comment has been minimized.
atlantis apply -d infra/us-east-1/mgmt/atlantis/alb |
This comment has been minimized.
This comment has been minimized.
atlantis show -d infra/us-east-1/mgmt/atlantis/key-pair |
|
atlantis apply |
This comment has been minimized.
This comment has been minimized.
atlantis unlock |
This comment has been minimized.
This comment has been minimized.
atlantis plan |
This comment has been minimized.
This comment has been minimized.
atlantis apply |
Ran Apply for 6 projects:
1. dir:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- infra/us-east-1/mgmt/atlantis/alb/terragrunt.hcl (1 hunks)
- infra/us-east-1/mgmt/ecr/terragrunt.hcl (1 hunks)
Files skipped from review due to trivial changes (1)
- infra/us-east-1/mgmt/ecr/terragrunt.hcl
Files skipped from review as they are similar to previous changes (1)
- infra/us-east-1/mgmt/atlantis/alb/terragrunt.hcl
Ran Plan for 6 projects:
4. dir:
|
project = local.environment_vars.locals.project | ||
cidr_prefix = local.environment_vars.locals.cidr_prefix | ||
tribe = local.account_vars.locals.tribe | ||
zone_id = "Z10147571DRRDCJXSER5Y" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get this from dependency outputs. We are managing that zone using Terraform.
See: https://github.com/input-output-hk/sc-dev-platform/blob/main/infra/global/route53/zones/terragrunt.hcl
tags = { | ||
Name = "${local.name}" | ||
Tribe = "${local.tribe}" | ||
Environment = "${local.env}" | ||
Project = "${local.project}" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary. Terragrunt is adding these tags automatically.
See: https://github.com/input-output-hk/sc-dev-platform/blob/main/infra/terragrunt.hcl#L70
user_data = <<-EOF | ||
#!/bin/bash | ||
sudo yum update -y | ||
sudo yum install -y docker | ||
sudo service docker start | ||
sudo usermod -a -G docker ec2-user | ||
EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the command to start the atlantis
container itself?
How are you starting it?
Summary by CodeRabbit