Skip to content

Commit e490e9e

Browse files
author
aleph
committed
chore: πŸš€ updated deploy file and terraform information
1 parent c8d3c8f commit e490e9e

File tree

7 files changed

+158
-20
lines changed

7 files changed

+158
-20
lines changed

β€Ž.github/workflows/deploy-staging.ymlβ€Ž

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,19 @@ name: Deploy to Staging (AWS S3 + CloudFront)
33
on:
44
push:
55
branches: [ develop, staging ]
6-
pull_request:
7-
branches: [ main ]
86
workflow_dispatch: # Allow manual trigger
97

108
permissions:
119
contents: read
1210
id-token: write # Required for AWS OIDC authentication
1311

14-
env:
15-
AWS_REGION: us-east-1
16-
S3_BUCKET: pythoncdmx-website-staging
17-
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_STAGING }}
1812

1913
jobs:
2014
build-and-deploy-staging:
2115
name: Build and Deploy to Staging
2216
runs-on: ubuntu-latest
2317
environment:
24-
name: staging
25-
url: https://staging.pythoncdmx.org
18+
name: aws-stag
2619
steps:
2720
- name: Checkout repository
2821
uses: actions/checkout@v4
@@ -59,40 +52,40 @@ jobs:
5952
uses: aws-actions/configure-aws-credentials@v4
6053
with:
6154
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
62-
aws-region: ${{ env.AWS_REGION }}
55+
aws-region: ${{ secrets.AWS_REGION }}
6356

6457
- name: Sync to S3 (Staging)
6558
run: |
66-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
59+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
6760
--delete \
6861
--cache-control "public, max-age=300" \
6962
--exclude "*.html" \
7063
--exclude "sitemap.xml"
7164
7265
# Upload HTML files with shorter cache for staging
73-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
66+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
7467
--cache-control "public, max-age=60, must-revalidate" \
7568
--content-type "text/html; charset=utf-8" \
7669
--exclude "*" \
7770
--include "*.html"
7871
7972
# Upload sitemap with no cache
80-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
73+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
8174
--cache-control "public, max-age=0, must-revalidate" \
8275
--exclude "*" \
8376
--include "sitemap.xml"
8477
8578
- name: Invalidate CloudFront cache
8679
run: |
8780
aws cloudfront create-invalidation \
88-
--distribution-id ${{ env.CLOUDFRONT_DISTRIBUTION_ID }} \
81+
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION }} \
8982
--paths "/*"
9083
9184
- name: Deployment summary
9285
run: |
9386
echo "βœ… Staging website deployed successfully!"
9487
echo "🌐 URL: https://staging.pythoncdmx.org"
95-
echo "πŸ“¦ S3 Bucket: ${{ env.S3_BUCKET }}"
96-
echo "πŸš€ CloudFront Distribution: ${{ env.CLOUDFRONT_DISTRIBUTION_ID }}"
88+
echo "πŸ“¦ S3 Bucket: ${{ secrets.AWS_S3_BUCKET }}"
89+
echo "πŸš€ CloudFront Distribution: ${{ secrets.CLOUDFRONT_DISTRIBUTION }}"
9790
echo ""
9891
echo "ℹ️ This is a STAGING environment for testing purposes."

β€Žterraform/.terraform.lock.hclβ€Ž

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žterraform/main.tfβ€Ž

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ terraform {
99
}
1010

1111
backend "s3" {
12-
bucket = "pythoncdmx-terraform-state"
13-
key = "website/terraform.tfstate"
14-
region = "us-east-1"
15-
encrypt = true
16-
dynamodb_table = "pythoncdmx-terraform-locks"
12+
bucket = "bucket-terraform-a8ab"
13+
key = "pythoncdmx/terraform.tfstate"
14+
region = "us-east-1"
15+
encrypt = true
1716
}
1817
}
1918

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "ACMCertificateManagement",
6+
"Effect": "Allow",
7+
"Action": [
8+
"acm:RequestCertificate",
9+
"acm:DescribeCertificate",
10+
"acm:ListCertificates",
11+
"acm:DeleteCertificate",
12+
"acm:AddTagsToCertificate",
13+
"acm:ListTagsForCertificate"
14+
],
15+
"Resource": "*"
16+
},
17+
{
18+
"Sid": "CloudFrontManagement",
19+
"Effect": "Allow",
20+
"Action": [
21+
"cloudfront:CreateDistribution",
22+
"cloudfront:GetDistribution",
23+
"cloudfront:GetDistributionConfig",
24+
"cloudfront:UpdateDistribution",
25+
"cloudfront:DeleteDistribution",
26+
"cloudfront:TagResource",
27+
"cloudfront:CreateOriginAccessControl",
28+
"cloudfront:GetOriginAccessControl",
29+
"cloudfront:UpdateOriginAccessControl",
30+
"cloudfront:DeleteOriginAccessControl",
31+
"cloudfront:CreateInvalidation",
32+
"cloudfront:GetInvalidation",
33+
"cloudfront:ListInvalidations"
34+
],
35+
"Resource": "*"
36+
},
37+
{
38+
"Sid": "Route53DNSManagement",
39+
"Effect": "Allow",
40+
"Action": [
41+
"route53:GetHostedZone",
42+
"route53:ListHostedZones",
43+
"route53:ListResourceRecordSets",
44+
"route53:ChangeResourceRecordSets",
45+
"route53:GetChange",
46+
"route53:ListTagsForResource"
47+
],
48+
"Resource": "*"
49+
},
50+
{
51+
"Sid": "S3BucketManagement",
52+
"Effect": "Allow",
53+
"Action": [
54+
"s3:CreateBucket",
55+
"s3:DeleteBucket",
56+
"s3:ListBucket",
57+
"s3:GetBucketLocation",
58+
"s3:GetBucketPolicy",
59+
"s3:PutBucketPolicy",
60+
"s3:DeleteBucketPolicy",
61+
"s3:GetBucketVersioning",
62+
"s3:PutBucketVersioning",
63+
"s3:GetBucketPublicAccessBlock",
64+
"s3:PutBucketPublicAccessBlock",
65+
"s3:GetBucketCORS",
66+
"s3:PutBucketCORS",
67+
"s3:GetEncryptionConfiguration",
68+
"s3:PutEncryptionConfiguration",
69+
"s3:GetLifecycleConfiguration",
70+
"s3:PutLifecycleConfiguration",
71+
"s3:GetBucketTagging",
72+
"s3:PutBucketTagging",
73+
"s3:GetObject",
74+
"s3:PutObject",
75+
"s3:DeleteObject",
76+
"s3:PutObjectAcl"
77+
],
78+
"Resource": [
79+
"arn:aws:s3:::pythoncdmx-website",
80+
"arn:aws:s3:::pythoncdmx-website/*",
81+
"arn:aws:s3:::pythoncdmx-website-staging",
82+
"arn:aws:s3:::pythoncdmx-website-staging/*"
83+
]
84+
},
85+
{
86+
"Sid": "IAMRoleManagement",
87+
"Effect": "Allow",
88+
"Action": [
89+
"iam:CreateOpenIDConnectProvider",
90+
"iam:GetOpenIDConnectProvider",
91+
"iam:DeleteOpenIDConnectProvider",
92+
"iam:TagOpenIDConnectProvider",
93+
"iam:CreateRole",
94+
"iam:GetRole",
95+
"iam:DeleteRole",
96+
"iam:UpdateAssumeRolePolicy",
97+
"iam:AttachRolePolicy",
98+
"iam:DetachRolePolicy",
99+
"iam:PutRolePolicy",
100+
"iam:GetRolePolicy",
101+
"iam:DeleteRolePolicy",
102+
"iam:ListRolePolicies",
103+
"iam:ListAttachedRolePolicies",
104+
"iam:TagRole",
105+
"iam:ListRoleTags"
106+
],
107+
"Resource": [
108+
"arn:aws:iam::700463753979:oidc-provider/token.actions.githubusercontent.com",
109+
"arn:aws:iam::700463753979:role/GitHubActionsDeployRole"
110+
]
111+
}
112+
]
113+
}

β€Žterraform/s3-staging.tfβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "website_staging" {
7676
id = "delete-old-versions"
7777
status = "Enabled"
7878

79+
filter {}
80+
7981
noncurrent_version_expiration {
8082
noncurrent_days = 30 # Shorter retention for staging
8183
}
@@ -85,6 +87,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "website_staging" {
8587
id = "delete-incomplete-uploads"
8688
status = "Enabled"
8789

90+
filter {}
91+
8892
abort_incomplete_multipart_upload {
8993
days_after_initiation = 3
9094
}

β€Žterraform/s3.tfβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "website" {
7575
id = "delete-old-versions"
7676
status = "Enabled"
7777

78+
filter {}
79+
7880
noncurrent_version_expiration {
7981
noncurrent_days = 90
8082
}
@@ -84,6 +86,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "website" {
8486
id = "delete-incomplete-uploads"
8587
status = "Enabled"
8688

89+
filter {}
90+
8791
abort_incomplete_multipart_upload {
8892
days_after_initiation = 7
8993
}

0 commit comments

Comments
Β (0)