-
Notifications
You must be signed in to change notification settings - Fork 3
chore: allow access to RDS from any source #122
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Show Terraform State | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
type: choice | ||
description: Environment to show state for | ||
options: | ||
- staging | ||
- production | ||
|
||
jobs: | ||
show-state: | ||
name: Show Terraform state for ${{ github.event.inputs.environment }} | ||
runs-on: ubuntu-latest | ||
environment: ${{ github.event.inputs.environment }} | ||
env: | ||
TF_VAR_AWS_REGION: ${{ vars.AWS_REGION }} | ||
TF_VAR_APP_NAME: ${{ vars.APP_NAME }} | ||
TF_VAR_APP_ENVIRONMENT: ${{ github.event.inputs.environment }} | ||
#Database | ||
TF_VAR_DATALAYER_PG_USER: ${{ secrets.DATALAYER_PG_USER }} | ||
TF_VAR_DATALAYER_PG_PASSWORD: ${{ secrets.DATALAYER_PG_PASSWORD }} | ||
#Hasura API | ||
TF_VAR_GREEN_DATALAYER_HASURA_ADMIN_SECRET: ${{ secrets.DATALAYER_HASURA_ADMIN_SECRET }} | ||
TF_VAR_BLUE_DATALAYER_HASURA_ADMIN_SECRET: ${{ secrets.DATALAYER_HASURA_ADMIN_SECRET }} | ||
#Coingecko API | ||
TF_VAR_GREEN_COINGECKO_API_KEY: ${{ secrets.COINGECKO_API_KEY }} | ||
TF_VAR_BLUE_COINGECKO_API_KEY: ${{ secrets.COINGECKO_API_KEY }} | ||
steps: | ||
- name: Check out github repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Check if user is an admin | ||
uses: ./.github/actions/check-admin | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ${{ vars.TERRAFORM_VERSION }} | ||
terraform_wrapper: false | ||
|
||
- name: Set up AWS CLI | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Terraform Init | ||
working-directory: deployment/environments/${{github.event.inputs.environment}} | ||
run: | | ||
terraform init \ | ||
-backend-config="bucket=${{ vars.APP_NAME }}-terraform-state" \ | ||
-backend-config="key=${{ vars.APP_NAME }}-${{github.event.inputs.environment}}-state" \ | ||
-backend-config="region=${{ vars.AWS_REGION }}" \ | ||
-backend-config="encrypt=true" | ||
|
||
- name: Show Terraform State | ||
working-directory: deployment/environments/${{github.event.inputs.environment}} | ||
run: | | ||
echo "=== Terraform State Information ===" | ||
echo "Current State:" | ||
terraform show | ||
|
||
echo -e "\n=== Terraform Outputs ===" | ||
terraform output | ||
|
||
echo -e "\n=== RDS Connection Information ===" | ||
echo "RDS Endpoint: $(terraform output -raw rds_endpoint)" | ||
echo "Connection String: postgresql://${{ secrets.DATALAYER_PG_USER }}:${{ secrets.DATALAYER_PG_PASSWORD }}@$(terraform output -raw rds_endpoint)/GitcoinDatalayer{{Green|Blue}}" | ||
|
||
echo -e "\n=== Current Deployment State ===" | ||
echo "Deployment State: $(terraform output -raw deployment_state)" | ||
echo "Active Deployment: $(terraform output -raw active_deployment)" | ||
|
||
echo -e "\n=== API Gateway Information ===" | ||
echo "API Gateway URL: $(terraform output -raw api_gateway_url)" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,14 @@ resource "aws_security_group" "rds" { | |
cidr_blocks = module.vpc.public_subnets_cidr_blocks # Allow access from public subnets | ||
} | ||
|
||
# Allow access from anywhere (0.0.0.0/0) | ||
ingress { | ||
from_port = 5432 | ||
to_port = 5432 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
Comment on lines
+74
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Critical security risk: Public RDS exposure Example refactor to make public ingress optional via a variable: @@ -74,7 +74,12 @@ resource "aws_security_group" "rds" {
- ingress {
- from_port = 5432
- to_port = 5432
- protocol = "tcp"
- cidr_blocks = ["0.0.0.0/0"]
+ # Public access controlled via variable
+ ingress {
+ from_port = 5432
+ to_port = 5432
+ protocol = "tcp"
+ cidr_blocks = var.rds_public_cidr_blocks
+ description = "Optional public RDS access"
} Add to your variables file: variable "rds_public_cidr_blocks" {
type = list(string)
description = "CIDR blocks allowed to access RDS publicly; leave empty to disable public access"
default = []
} 🤖 Prompt for AI Agents
|
||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ module "rds" { | |
|
||
maintenance_window = "Mon:00:00-Mon:03:00" | ||
|
||
publicly_accessible = false | ||
publicly_accessible = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Security Concern: Exposing RDS to the public Internet Suggested refactor: - publicly_accessible = true
+ publicly_accessible = var.rds_publicly_accessible And in +variable "rds_publicly_accessible" {
+ description = "Whether the RDS instance is publicly accessible"
+ type = bool
+ default = false
+} Additionally, enforce tighter network controls (whitelisted CIDRs or VPN/bastion), and enable features like Would you like help wiring up the variable or locking down the allowed CIDRs? 🤖 Prompt for AI Agents
|
||
|
||
storage_encrypted = true | ||
|
||
|
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.
🛠️ Refactor suggestion
Avoid exposing credentials in logs & correct the placeholder
Echoing the full connection string (including
${{ secrets.DATALAYER_PG_PASSWORD }}
) risks leaking sensitive data—even if GitHub masks secrets—and the literal{{Green|Blue}}
will not resolve to the active environment. Instead, mask or omit the password in the log and interpolate the${active_deployment}
shell variable for the database name.Suggested diff:
📝 Committable suggestion
🤖 Prompt for AI Agents