Skip to content

Commit

Permalink
Merge pull request #7 from primeharbor/test
Browse files Browse the repository at this point in the history
Merge Changes to create a proper links file for these CFTs
  • Loading branch information
jchrisfarris authored Dec 9, 2023
2 parents e492e03 + c943a13 commit a3ea804
Show file tree
Hide file tree
Showing 7 changed files with 501 additions and 1,382 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/index_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3

import boto3
import os
import urllib.parse

client = boto3.client('s3')

bucket = os.environ['S3_BUCKET']

response = client.list_objects_v2(
Bucket=bucket,
Prefix='aws-account-automation/'
)

for o in response['Contents']:
url = f"https://{bucket}.s3.amazonaws.com/{o['Key']}"
print(f"## {o['Key']}")
print(f"* [Quick Deploy URL](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?templateURL={urllib.parse.quote(url)})")
print(f"* [HTTP URL (latest)]({url})")
print(f"* S3 URL (latest) - s3://{bucket}/{o['Key']}")
print("* Previous Version HTTP URLs:")
r2 = client.list_object_versions(
Bucket=bucket,
Prefix=o['Key']
)
for v in r2['Versions']:
print(f"\t * [{v['LastModified']} ({v['VersionId']})](https://{bucket}.s3.amazonaws.com/{o['Key']}?versionId={v['VersionId']})")

14 changes: 5 additions & 9 deletions .github/workflows/sync-to-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ jobs:
--s3-prefix aws-account-automation-lambda-transform --output-template-file cloudformation/BillingMetrics-Template-Transformed.yaml \
--metadata build_ver=$(git rev-parse --short "$GITHUB_SHA")
aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/
for object in `aws s3api list-objects-v2 --bucket ${S3_BUCKET} --prefix aws-account-automation/ --query Contents[].[Key] --output text` ; do
aws s3api list-object-versions --bucket ${S3_BUCKET} --prefix ${object} --query Versions[].[Key,VersionId,LastModified] --output text --max-items 3
done | grep -v ^None$ > Latest-Versions.txt
aws s3api list-object-versions --bucket pht-cloudformation --prefix aws-account-automation/ --query Versions[].[Key,VersionId,LastModified] --output text > Versions.txt
aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/ --content-type text/plain
pip install boto3
.github/workflows/index_files.py > Test-Links.md
git config user.name github-actions
git config user.email [email protected]
git add Versions.txt Latest-Versions.txt
git commit -m "AutoGenerated Object Versions"
git add Links.md
git commit -m "AutoGenerated Links File"
git push
env:
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/sync-to-test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Sync Test Branch to S3

permissions:
contents: write

on:
push:
branches:
Expand All @@ -10,14 +13,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Run Sync
run: |
aws cloudformation package --template-file cloudformation/BillingMetrics-Template.yaml --s3-bucket ${S3_BUCKET} \
--s3-prefix aws-account-automation-lambda-transform --output-template-file cloudformation/BillingMetrics-Template-Transformed.yaml \
--metadata build_ver=$(git rev-parse --short "$GITHUB_SHA")
aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/
aws s3 sync --delete cloudformation/ s3://${S3_BUCKET}/aws-account-automation/ --content-type text/plain
pip install boto3
.github/workflows/index_files.py > Test-Links.md
git checkout test
git config user.name github-actions
git config user.email [email protected]
git add Test-Links.md
git commit -m "AutoGenerated Links File"
git push origin HEAD:test
env:
S3_BUCKET: pht-cloudformation-dev
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
80 changes: 0 additions & 80 deletions Latest-Versions.txt

This file was deleted.

46 changes: 1 addition & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,5 @@ Tools to Automate your AWS Account


## Hosting
The most recent version of all these templates are hosted in S3 for Easy Deployment.

Directly callable URLS:
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AWSCloudFormationStackSetRoles-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AWSConfigAggregator-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AWSConfigRecorder-StackSetTemplate.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AWSConfigRecorder-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AccountAlertTopics-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AuditRole-StackSetTemplate.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/AuditRole-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/BillingBucket-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/BillingMetrics-Template-Transformed.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/BillingMetrics-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/CloudTrail-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/CloudTrailConfigBucket-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/CloudWatchAlarmsForCloudTrailAPIActivity-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/EBSAutomatedTagging.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/GuardDuty-to-Slack-StackSetTemplate.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/GuardDuty-to-Slack-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/IAM-ExpireUsers-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/OrgCloudTrail-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/requireMFA-Template.yaml
* https://s3.amazonaws.com/pht-cloudformation/aws-account-automation/SESRuleToSlack-Template.yaml

S3 Paths:
* s3://pht-cloudformation/aws-account-automation/AWSCloudFormationStackSetRoles-Template.yaml
* s3://pht-cloudformation/aws-account-automation/AWSConfigAggregator-Template.yaml
* s3://pht-cloudformation/aws-account-automation/AWSConfigRecorder-StackSetTemplate.yaml
* s3://pht-cloudformation/aws-account-automation/AWSConfigRecorder-Template.yaml
* s3://pht-cloudformation/aws-account-automation/AccountAlertTopics-Template.yaml
* s3://pht-cloudformation/aws-account-automation/AuditRole-StackSetTemplate.yaml
* s3://pht-cloudformation/aws-account-automation/AuditRole-Template.yaml
* s3://pht-cloudformation/aws-account-automation/BillingBucket-Template.yaml
* s3://pht-cloudformation/aws-account-automation/BillingMetrics-Template-Transformed.yaml
* s3://pht-cloudformation/aws-account-automation/BillingMetrics-Template.yaml
* s3://pht-cloudformation/aws-account-automation/CloudTrail-Template.yaml
* s3://pht-cloudformation/aws-account-automation/CloudTrailConfigBucket-Template.yaml
* s3://pht-cloudformation/aws-account-automation/CloudWatchAlarmsForCloudTrailAPIActivity-Template.yaml
* s3://pht-cloudformation/aws-account-automation/EBSAutomatedTagging.yaml
* s3://pht-cloudformation/aws-account-automation/GuardDuty-to-Slack-StackSetTemplate.yaml
* s3://pht-cloudformation/aws-account-automation/GuardDuty-to-Slack-Template.yaml
* s3://pht-cloudformation/aws-account-automation/IAM-ExpireUsers-Template.yaml
* s3://pht-cloudformation/aws-account-automation/OrgCloudTrail-Template.yaml
* s3://pht-cloudformation/aws-account-automation/requireMFA-Template.yaml
* s3://pht-cloudformation/aws-account-automation/SESRuleToSlack-Template.yaml
The most recent version of all these templates are hosted in S3 for Easy Deployment. You can find the latest HTTP URL, S3 URL, QuickDeploy Links and HTTP URLs for previous versions in the [Links.md](Links.md) file.

Loading

0 comments on commit a3ea804

Please sign in to comment.