Skip to content

Commit 7387034

Browse files
authored
One click deploy and cleanup (#1)
1 parent 79693ab commit 7387034

File tree

5 files changed

+436
-123
lines changed

5 files changed

+436
-123
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy CloudFormation Template to S3
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'infrastructure/templates/cloudfront.yaml'
9+
- 'infrastructure/templates/remove-cloudfront.yaml'
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
deploy-template:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
id-token: write
19+
contents: read
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Configure AWS credentials
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
29+
aws-region: ${{ vars.AWS_REGION }}
30+
31+
- name: Upload CloudFormation templates to S3
32+
run: |
33+
echo "Uploading CloudFront template to s3://${{ vars.S3_BUCKET }}/${{ vars.S3_FILE_KEY }}"
34+
aws s3 cp infrastructure/templates/cloudfront.yaml s3://${{ vars.S3_BUCKET }}/${{ vars.S3_FILE_KEY }}
35+
36+
echo "Uploading cleanup template to s3://${{ vars.S3_BUCKET }}/remove-cloudfront.yaml"
37+
aws s3 cp infrastructure/templates/remove-cloudfront.yaml s3://${{ vars.S3_BUCKET }}/remove-cloudfront.yaml
38+
39+
# Verify uploads
40+
echo "Verifying template accessibility..."
41+
curl -f -I https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }}
42+
curl -f -I https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml
43+
44+
echo "✅ Templates successfully deployed!"
45+
echo "CloudFront Template URL: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }}"
46+
echo "Cleanup Template URL: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml"
47+
48+
- name: Update deployment status
49+
run: |
50+
echo "::notice title=Templates Deployed::CloudFormation templates updated - CloudFront: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }}, Cleanup: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.scratch
1+
.scratch/

README.md

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,31 @@ aws sts get-caller-identity
2121
aws sso login --profile YOUR-PROFILE
2222
```
2323

24+
## 🚀 One-Click Deploy
25+
26+
Deploy the CloudFront reverse proxy directly from the AWS Console with pre-configured settings.
27+
28+
| Region | Launch Stack | Console Link |
29+
|--------|--------------|--------------|
30+
| **US East (N. Virginia)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) |
31+
| **US East (Ohio)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) |
32+
| **US West (Oregon)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) |
33+
| **EU West (Ireland)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml&stackName=ld-cloudfront-proxy&param_UseCustomDomain=false&param_PriceClass=PriceClass_100&param_EnableLogging=false) |
34+
35+
You can deploy to any AWS region by changing `region=us-east-1` in the URL to your preferred region (e.g., `region=ap-southeast-1`).
36+
37+
**Template URL:** `https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/cloudfront.yaml`
38+
39+
The template is automatically updated via GitHub Actions when changes are merged to main for `infrastructure/cloudfront.yaml`
40+
2441
## Configuration Options
2542

2643
| Parameter | Default | Options | Description |
2744
|-----------|---------|---------|-------------|
2845
| `UseCustomDomain` | `false` | `true`/`false` | Use your own domain instead of CloudFront default |
29-
| `DomainName` | `""` | Your domain | Required if UseCustomDomain=true (e.g., `flags.my-super-awesome-company.com`) |
46+
| `DomainName` | `""` | Your domain | Required if UseCustomDomain=true (e.g., `flags.my-company.com`) currently we only support one sub-domain |
3047
| `AcmCertificateArn` | `""` | ACM ARN | Required if UseCustomDomain=true (must be in us-east-1) |
31-
| `AutoCreateDNS` | `false` | `true`/`false` | **NEW:** Automatically create Route 53 DNS record |
48+
| `AutoCreateDNS` | `false` | `true`/`false` | Automatically create Route 53 DNS record |
3249
| `HostedZoneId` | `""` | Route 53 Zone ID | Required if AutoCreateDNS=true (e.g., `Z1D633PJN98FT9`) |
3350
| `PriceClass` | `PriceClass_100` | `PriceClass_100`/`200`/`All` | Coverage: US/Canada/Europe/Asia (100) vs Global (All) |
3451
| `EnableLogging` | `false` | `true`/`false` | Enable CloudFront access logging |
@@ -40,70 +57,22 @@ aws sso login --profile YOUR-PROFILE
4057
- **PriceClass_200**: Adds Middle East, Africa - Medium cost
4158
- **PriceClass_All**: Global coverage - Highest cost
4259

43-
### Custom Domain Setup Options
44-
45-
**⚠️ PREREQUISITES:** Before using `UseCustomDomain=true`, you must complete the following setup!!
4660

47-
#### Step 1: Get Your Route 53 Hosted Zone ID
48-
```bash
49-
# Find your hosted zone ID (replace with your domain)
50-
aws route53 list-hosted-zones --query 'HostedZones[?Name==`my-awesome-domain.com.`].[Id,Name]' --output table
51-
52-
# Example output: Zone ID like Z01741713N143BEH1HBBD
53-
```
54-
55-
#### Step 2: Create ACM Certificate (Required)
56-
```bash
57-
# Request SSL certificate (MUST be in us-east-1 for CloudFront)
58-
aws acm request-certificate \
59-
--domain-name flags.my-awesoome-domain.com \
60-
--validation-method DNS \
61-
--region us-east-1
62-
63-
# Save the Certificate ARN from the output!
64-
```
65-
66-
#### Step 3: Validate Certificate
67-
```bash
68-
# Get DNS validation record details
69-
aws acm describe-certificate --certificate-arn YOUR-CERT-ARN --region us-east-1
70-
71-
# Create validation record in Route 53 (replace with your values)
72-
aws route53 change-resource-record-sets --hosted-zone-id YOUR-ZONE-ID --change-batch '{
73-
"Changes": [{
74-
"Action": "CREATE",
75-
"ResourceRecordSet": {
76-
"Name": "_validation-string.flags.my-awesome-domain.com.",
77-
"Type": "CNAME",
78-
"TTL": 300,
79-
"ResourceRecords": [{"Value": "_validation-value.acm-validations.aws."}]
80-
}
81-
}]
82-
}'
83-
84-
# Verify certificate is issued...this will take a few minutes
85-
aws acm describe-certificate --certificate-arn YOUR-CERT-ARN --region us-east-1 \
86-
--query 'Certificate.Status' --output text
87-
# Should return: ISSUED
88-
```
89-
90-
Once validated, proceed to Option 1 for deployment. If you are not using a custom domain, use Option 2 for deployment.
9161

9262
### Option 1: AWS CloudFront Reverse proxy with Custom DNS
9363

9464
**Deployment time:** ~15-20 minutes (CloudFront global propagation)
9565

96-
If you have a Route 53 hosted zone, the template can automatically create DNS records.
66+
If you have a Route 53 hosted zone, the template can automatically create the certificate and DNS records. Ensure you already have the hosted zone setup.
9767

98-
NOTE: Ensure you have followed the above steps in the Custom Domain Setup Options section prior to running the below command.
9968

10069
```bash
10170
aws cloudformation deploy \
10271
--template-file templates/cloudfront.yaml \
10372
--stack-name ld-cloudfront-proxy \
10473
--parameter-overrides \
10574
UseCustomDomain=true \
106-
DomainName=flags.my-awesome-domain.com \
75+
DomainName=flags.my-company-domain.com \
10776
AcmCertificateArn=my-awesome-arn \
10877
AutoCreateDNS=true \
10978
HostedZoneId=my-awesome-hosted-zone-id \
@@ -120,7 +89,7 @@ aws cloudformation describe-stacks \
12089
--output table
12190
```
12291

123-
This will return your CloudFront domain (e.g., `flags.my-awesome-domain.com`)
92+
This will return your CloudFront domain (e.g., `flags.my-company-domain.com`)
12493

12594

12695
### Option 2: AWS CloudFront Reverse proxy with generic DNS
@@ -150,7 +119,7 @@ aws cloudformation describe-stacks \
150119

151120
This will return your CloudFront domain: `d4a2b1c1d5e6f9.cloudfront.net`
152121

153-
## 📱 SDK Configuration
122+
## SDK Configuration
154123

155124
Once deployed, configure your LaunchDarkly SDKs to use your CloudFront proxy by specifying the options with the reverse proxy URL.
156125

@@ -163,14 +132,14 @@ const LDProvider = await asyncWithLDProvider({
163132
key: "unique-device-id"
164133
},
165134
options: {
166-
baseUrl: 'https://flags.my-awesome-domain.com',
167-
eventsUrl: 'https://flags.my-awesome-domain.com',
168-
streamUrl: 'https://flags.my-awesome-domain.com'
135+
baseUrl: 'https://flags.my-company-domain.com',
136+
eventsUrl: 'https://flags.my-company-domain.com',
137+
streamUrl: 'https://flags.my-company-domain.com
169138
}
170139
});
171140
```
172141
173-
You may need to restart your application.
142+
NOTE: You may need to restart your application.
174143
175144
## What Gets Deployed
176145
@@ -245,3 +214,34 @@ Different LaunchDarkly projects within the same organization can use different c
245214
- **Project C**: Uses a different proxy or region
246215
247216
Each project configures its SDK independently using different SDK keys and base URLs.
217+
218+
## Github Actions: Automated Template Deployment to s3 bucket
219+
220+
This repository includes a GitHub Actions workflow that automatically updates the S3-hosted CloudFormation templates when changes are merged to main.
221+
222+
## One-Click Cleanup
223+
224+
Remove your CloudFront proxy deployment and clean up all associated resources including DNS records and certificates.
225+
226+
### Cleanup Options
227+
228+
| Region | Launch Cleanup Stack | Console Link |
229+
|--------|---------------------|--------------|
230+
| **US East (N. Virginia)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) |
231+
| **US East (Ohio)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) |
232+
| **US West (Oregon)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) |
233+
| **EU West (Ireland)** | [![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) | [Text Link](https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create/review?templateURL=https://ld-cloudfront-proxy-templates-09-25-25.s3.amazonaws.com/remove-cloudfront.yaml&stackName=cleanup-ld-cloudfront&param_StackNameToDelete=ld-cloudfront-proxy&param_CleanupDNS=true&param_CleanupCertificate=true) |
234+
235+
### Required Parameters
236+
237+
Before clicking cleanup, you'll need to provide:
238+
239+
- **StackNameToDelete**: Name of your CloudFront stack (default: `ld-cloudfront-proxy`)
240+
- **DomainName**: Your custom domain (e.g., `flags.your-company.com`) - leave empty to skip DNS/cert cleanup
241+
- **CleanupDNS**: Set to `true` to remove Route 53 DNS records
242+
- **CleanupCertificate**: Set to `true` to remove ACM certificates
243+
244+
> **⚠️ Warning:** This will permanently delete your CloudFront proxy and all associated resources. Make sure you're ready before proceeding!
245+
246+
---
247+

0 commit comments

Comments
 (0)