Skip to content

Commit 0742a91

Browse files
authored
Making it work gooder (#215)
- remove cloudfront and WAF, just using raw ALB and allowlisting - add mergeable tags
1 parent 4814f99 commit 0742a91

11 files changed

Lines changed: 24 additions & 142 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ name: pytest
99

1010
jobs:
1111
pytest:
12+
permissions:
13+
# Gives the action the necessary permissions for publishing new
14+
# comments in pull requests.
15+
pull-requests: write
1216
runs-on: ubuntu-latest
1317
steps:
1418
- uses: actions/checkout@v5
@@ -23,4 +27,13 @@ jobs:
2327
python -m pip install --quiet --no-cache-dir --upgrade uv
2428
uv run pytest
2529
uv run coverage run --source=thin_controller -m pytest
30+
- name: Upload coverage to Coveralls
31+
run: |
2632
uv run coveralls
33+
continue-on-error: true
34+
35+
- name: Coverage comment
36+
id: coverage_comment
37+
uses: py-cov-action/python-coverage-comment-action@v3
38+
with:
39+
GITHUB_TOKEN: ${{ github.token }}

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ thin-controller is a FastAPI-based web application that controls AWS EC2 instanc
1919
## Development Commands
2020

2121
### Running the Application
22+
2223
```bash
2324
# Start development server with auto-reload
2425
uv run thin-controller --reload
@@ -28,6 +29,7 @@ uv run thin-controller
2829
```
2930

3031
### Testing and Quality Checks
32+
3133
```bash
3234
# Run all checks (lint + types + test)
3335
just check
@@ -52,6 +54,7 @@ just coverage
5254
```
5355

5456
### Container
57+
5558
```bash
5659
# Build Docker container
5760
just build_container
@@ -69,6 +72,7 @@ docker build -t ghcr.io/yaleman/thin-controller:latest .
6972
## AWS Lambda Deployment
7073

7174
The Terraform module creates:
75+
7276
- Lambda layer with dependencies (built using `pip install` into `thin_controller_layer/`)
7377
- Lambda function using the `terraform_lambda` module (v1.0.9)
7478
- Python 3.12 runtime with 30-second timeout
@@ -78,6 +82,7 @@ The layer building process uses `python3.13` locally but targets `python3.12` ru
7882
## State Management
7983

8084
Instance state changes follow strict rules in `STATE_CHANGES`:
85+
8186
- `running` → can only `stop`
8287
- `stopped` → can only `start`
8388
- Other states (`pending`, `shutting-down`, `terminated`, `stopping`) are not directly actionable

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ WORKDIR /home/nonroot
1616

1717
EXPOSE 8000
1818

19-
ENTRYPOINT ["/home/nonroot/.local/bin/thin-controller", "--host", "0.0.0.0"]
19+
ENTRYPOINT ["/home/nonroot/.local/bin/thin-controller", "--host", "0.0.0.0"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ omit = [
5858
"terraform/*", # no python here
5959
"thin_controller/handler.py", # only a stub for the Lambda handler
6060
]
61+
relative_files = true

terraform/cloudfront.tf

Lines changed: 0 additions & 69 deletions
This file was deleted.

terraform/fargate.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,5 @@ output "alb_dns_name" {
326326

327327
output "connection_info" {
328328
description = "How to connect to the application"
329-
value = var.use_fargate ? "Use CloudFront URL (see cloudfront_url output)" : null
329+
value = var.use_fargate ? "Use ALB URL: http://${aws_lb.thin_controller_alb[0].dns_name}" : null
330330
}

terraform/lambda_iam.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ resource "aws_iam_policy" "lambda_ec2_policy" {
4141
# Attach the policy to the Lambda function role
4242
resource "aws_iam_role_policy_attachment" "lambda_ec2_policy_attachment" {
4343
count = var.use_lambda ? 1 : 0
44-
role = module.thin_controller_module[0].lambda_role_name
44+
role = module.thin_controller_module[0].role_name
4545
policy_arn = aws_iam_policy.lambda_ec2_policy[0].arn
4646
}

terraform/providers.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,3 @@ provider "aws" {
1313
region = var.aws_region
1414
}
1515

16-
# CloudFront WAF must be in us-east-1
17-
provider "aws" {
18-
alias = "us-east-1"
19-
profile = var.aws_profile
20-
region = "us-east-1"
21-
}

terraform/terraform.tfvars.example

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@ vpc_id = "vpc-xxxxxxxx"
1212
public_subnet_ids = ["subnet-xxxxxxxx", "subnet-yyyyyyyy"] # For NLB
1313
private_subnet_ids = ["subnet-aaaaaaaa", "subnet-bbbbbbbb"] # For ECS tasks
1414

15-
# Security - IP allow list for inbound traffic (optional, not used with NLB)
16-
# NLB doesn't support security groups, so IP filtering must be done at task level
15+
# Security - IP allow list for inbound traffic
1716
ip_allow_list_inbound = []
1817

19-
# Security - Managed prefix lists for inbound traffic (optional, not used with NLB)
18+
# Security - Managed prefix lists for inbound traffic (e.g., "pl-xxxxxxxxx")
2019
managed_prefix_list_ids_allow_inbound = []
2120

2221
# Application Configuration
2322
thin_controller_regions = "us-east-1,us-west-2"
2423
public_hostname = "thin-controller.example.com"
2524

26-
# CloudFront Configuration (if using CloudFront)
27-
cloudfront_geo_regions = ["US", "AU"]
28-
2925
# Common tags applied to all resources
3026
tags = {
3127
Environment = "production"

terraform/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ variable "use_fargate" {
2626
default = false
2727
}
2828

29-
variable "cloudfront_geo_regions" {
30-
description = "Cloudfront geo whitelist regions, allowing source IPs"
31-
type = list(string)
32-
default = ["US", "AU"]
33-
}
34-
3529
variable "thin_controller_regions" {
3630
description = "Comma-delimited list of regions to check/control"
3731
type = string

0 commit comments

Comments
 (0)