This repository was archived by the owner on Jan 25, 2026. It is now read-only.
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a dedicated EC2 spot instance for database access and updates security group configurations to accommodate it.
- Adds a new
ec2module with variables and a spot instance resource - Creates and exposes a
sg_db_access_instancesecurity group; updates existing groups to allow access - Integrates the new module into
main.tf
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| main.tf | Integrated the new ec2 module |
| Modules/SecurityGroup/main.tf | Added sg_db_access_instance SG and updated egress/ingress |
| Modules/SecurityGroup/outputs.tf | Added output for sg_db_access_instance_id |
| Modules/EC2/variables.tf | Defined inputs for public subnets and SG ID |
| Modules/EC2/main.tf | Implemented the spot instance resource |
Comments suppressed due to low confidence (1)
main.tf:55
- The new EC2 module and its security group interactions should have automated tests (e.g., using Terratest or similar) to verify provisioning and connectivity.
module "ec2" {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new EC2 module to provision a spot instance for database access and updates the security group configurations to support this instance. The changes include defining the necessary resources, variables, and outputs, as well as integrating the new module into the main infrastructure configuration.
EC2 Module Implementation:
aws_instanceresource inModules/EC2/main.tfto create a spot instance using the latest Amazon Linux 2 AMI. This instance is tagged asdummy-db-access-instanceand is associated with a public IP. ([Modules/EC2/main.tfR1-R29](https://github.com/dutymate/infrastructure/pull/3/files#diff-55692756cb1a298134c71fccdd03f55f2eed57b252432187ba7dc59e88aaa580R1-R29))public_subnetsandsg_db_access_instance_idinModules/EC2/variables.tfto parameterize the subnet and security group for the instance. ([Modules/EC2/variables.tfR1-R7](https://github.com/dutymate/infrastructure/pull/3/files#diff-12f99cff164434fad4c8bd4ff5cb61328cf5231842fc4fbaff4475415c76b3f6R1-R7))Security Group Updates:
sg_db_access_instanceinModules/SecurityGroup/main.tfto allow SSH ingress from any IP and unrestricted egress. ([Modules/SecurityGroup/main.tfR157-R175](https://github.com/dutymate/infrastructure/pull/3/files#diff-29818b55ae9cc398e9749b8de85a02e76cee370b675117076252b8ab335a6bb3R157-R175))sg_mysql,sg_valkey,sg_mongodb) to includesg_db_access_instancefor secure communication with the new instance. ([[1]](https://github.com/dutymate/infrastructure/pull/3/files#diff-29818b55ae9cc398e9749b8de85a02e76cee370b675117076252b8ab335a6bb3L97-R97),[[2]](https://github.com/dutymate/infrastructure/pull/3/files#diff-29818b55ae9cc398e9749b8de85a02e76cee370b675117076252b8ab335a6bb3L120-R120),[[3]](https://github.com/dutymate/infrastructure/pull/3/files#diff-29818b55ae9cc398e9749b8de85a02e76cee370b675117076252b8ab335a6bb3L143-R143))Outputs and Integration:
sg_db_access_instance_idinModules/SecurityGroup/outputs.tfto expose the new security group ID. ([Modules/SecurityGroup/outputs.tfR5-R8](https://github.com/dutymate/infrastructure/pull/3/files#diff-20aa32128be1843d003a3b4ffad1da7c7c12a6b6bbd2e438f4ee21284c39eb7eR5-R8))main.tffile, passing the required subnet and security group as inputs. ([main.tfR55-R60](https://github.com/dutymate/infrastructure/pull/3/files#diff-dc46acf24afd63ef8c556b77c126ccc6e578bc87e3aa09a931f33d9bf2532fbbR55-R60))