Skip to content

Commit 2f8e9de

Browse files
authored
Merge pull request #147 from MLPlatformWebsite/pjc-transfer-linaro-scripts
Remove more profile references
2 parents 5ae33f0 + ea8b505 commit 2f8e9de

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

.github-env-master

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
AWS_STATIC_SITE_PROFILE=mlplatform-org-buildbot
21
AWS_STATIC_SITE_URL=production-mlplatform-org
32
CF_DIST_ID_STATIC_LO=E2U7UQCLK7G1EJ
43
CLOUDFRONT_ADD_SECURITY_HEADERS_ARN=arn:aws:lambda:us-east-1:841045539419:function:cloudfront-add-security-headers:1

tools/invalidate-cloudfront.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ NEW_CHANGES="/*"
55

66
echo "======== CREATING INVALIDATION ========"
77
echo "--distribution-id \"$CF_DIST_ID_STATIC_LO\" --paths $NEW_CHANGES"
8-
invID=$(aws --profile "$AWS_STATIC_SITE_PROFILE" cloudfront create-invalidation \
9-
--distribution-id "$CF_DIST_ID_STATIC_LO" --paths "$NEW_CHANGES" --query Invalidation.Id --output text)
8+
invID=$(aws cloudfront create-invalidation --distribution-id "$CF_DIST_ID_STATIC_LO" --paths "$NEW_CHANGES" --query Invalidation.Id --output text)
109
export invID
1110

1211
echo "======== INVALIDATION ID ========"
@@ -16,18 +15,15 @@ echo "======== POLLING COMPLETED INVALIDATION ========"
1615
# Increasingly, a single call to cloudfront wait invalidation-completed has been erroring
1716
# out with "max attempts exceeded". We now run this in a do loop to ensure that we repeat
1817
# the call until it is all finished.
19-
until aws --profile "$AWS_STATIC_SITE_PROFILE" cloudfront wait invalidation-completed \
20-
--distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}" 2>/dev/null
18+
until aws cloudfront wait invalidation-completed --distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}" 2>/dev/null
2119
do
2220
# Still waiting - output some progress
2321
echo "Still waiting ..."
24-
aws --profile "$AWS_STATIC_SITE_PROFILE" cloudfront get-invalidation \
25-
--distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}"
22+
aws cloudfront get-invalidation --distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}"
2623
sleep 10
2724
done
2825

2926
# and final confirmation
30-
aws --profile "$AWS_STATIC_SITE_PROFILE" cloudfront get-invalidation \
31-
--distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}"
27+
aws cloudfront get-invalidation --distribution-id "$CF_DIST_ID_STATIC_LO" --id "${invID}"
3228

3329
echo "======== INVALIDATION COMPLETED ========"

tools/lambda-security-headers.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import boto3
88

99

10-
_PROFILE = (
11-
"AWS_STATIC_SITE_PROFILE"
12-
)
1310
_CFDIST = (
1411
"CF_DIST_ID_STATIC_LO"
1512
)
@@ -31,8 +28,7 @@ def get_env_var(env):
3128

3229
def build_lambda_arn(function_name) -> str:
3330
""" Get the latest version for the function """
34-
profile = get_env_var(_PROFILE)
35-
session = boto3.Session(profile_name=profile)
31+
session = boto3.Session()
3632
client = session.client('lambda', 'us-east-1')
3733
versions = client.list_versions_by_function(FunctionName=function_name)["Versions"]
3834
# Find the highest version number
@@ -61,8 +57,7 @@ def get_lambda_arn() -> str:
6157
def is_function_attached():
6258
""" Is the function attached to the distribution? """
6359
func = get_lambda_arn()
64-
profile = get_env_var(_PROFILE)
65-
session = boto3.Session(profile_name=profile)
60+
session = boto3.Session()
6661
cf_client = session.client('cloudfront', 'us-east-1')
6762
config = cf_client.get_distribution_config(
6863
Id=get_env_var(_CFDIST)
@@ -88,8 +83,7 @@ def attach_function():
8883
"EventType": "origin-response",
8984
"LambdaFunctionARN": func
9085
}
91-
profile = get_env_var(_PROFILE)
92-
session = boto3.Session(profile_name=profile)
86+
session = boto3.Session()
9387
cf_client = session.client('cloudfront', 'us-east-1')
9488
config = cf_client.get_distribution_config(
9589
Id=get_env_var(_CFDIST)

0 commit comments

Comments
 (0)