Skip to content

Commit 38bc7ff

Browse files
committed
Alterations to proxygen set up and workflows
1 parent 77e7916 commit 38bc7ff

4 files changed

Lines changed: 34 additions & 45 deletions

File tree

.github/workflows/publish-specification.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,12 @@ jobs:
4545
pip install proxygen-cli
4646
4747
- name: Set up Proxygen credentials
48+
env:
49+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY_PROD }}
4850
run: |
4951
mkdir -p ~/.proxygen
50-
51-
if [ "${{ env.APIM_ENV }}" = "preprod" ]; then
52-
ENV_PARAM="ptl"
53-
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY_PTL }}
54-
else
55-
ENV_PARAM="${{ env.APIM_ENV }}"
56-
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY_PROD }}
57-
fi
58-
59-
echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api-${ENV_PARAM}.pem
60-
make setup-proxygen-credentials ENV=${ENV_PARAM}
52+
echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem
53+
make setup-proxygen-credentials ENV=prod
6154
6255
- name: Generate specification
6356
run: |

.github/workflows/publish_sandbox.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ jobs:
4040
4141
- name: Set up Proxygen credentials
4242
env:
43-
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
43+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY_PROD }}
4444
run: |
4545
mkdir -p ~/.proxygen
4646
echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem
47-
make setup-proxygen-credentials
47+
make setup-proxygen-credentials ENV=prod
4848
4949
- name: Generate sandbox specification
5050
run: |

Makefile

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,60 @@ config:: # Configure development environment (main) @Configuration
5353
#### Proxygen ####
5454
##################
5555

56+
# Proxygen key only exists in our 'dev' AWS Parameter Store
57+
PROXYGEN_ENV ?= dev
58+
59+
# Specs are published in the APIM 'prod' environment
60+
APIM_ENV ?= prod
61+
62+
# retrieve-proxygen-key: # Obtain the 'machine user' credentials from AWS SSM (Development environment)
63+
# mkdir -p ~/.proxygen && \
64+
# aws ssm get-parameter --name /proxygen/private_key_temp --with-decryption | jq ".Parameter.Value" --raw-output \
65+
# > ~/.proxygen/eligibility-signposting-api.pem
66+
#
67+
# setup-proxygen-credentials: # Copy Proxygen templated credentials to where it expected them
68+
# cd specification && cp -r .proxygen ~
69+
5670
# Verify current AWS account login and retrieve the proxygen key
57-
# from AWS SSM for the specified environment
58-
retrieve-proxygen-key: guard-ENV
59-
@ ./scripts/check-aws-account.sh $(ENV)
71+
# from AWS SSM Parameter Store
72+
retrieve-proxygen-key:
73+
@ ./scripts/check-aws-account.sh $(PROXYGEN_ENV)
6074
mkdir -p ~/.proxygen
61-
@ AWS_ENV=$$([ "$(ENV)" = "ptl" ] && echo "preprod" || echo "$(ENV)"); \
62-
aws ssm get-parameter --name /$$AWS_ENV/proxygen/private_key --with-decryption \
75+
aws ssm get-parameter --name /$$PROXYGEN_ENV/proxygen/private_key --with-decryption \
6376
| jq -r ".Parameter.Value" \
64-
> ~/.proxygen/eligibility-signposting-api-$(ENV).pem && \
65-
echo "Retrieved proxygen key for '$(ENV)' environment"
77+
> ~/.proxygen/eligibility-signposting-api-$(APIM_ENV).pem && \
78+
echo "Retrieved proxygen key for APIM '$(APIM_ENV)' environment"
6679

6780
# Copy proxygen credentials for the specified environment to `~/.proxygen/`
6881
# This location required location for local proxygen usage
6982
setup-proxygen-credentials: guard-ENV
7083
@ cd specification && \
7184
cp .proxygen/credentials-$(ENV).yaml ~/.proxygen/credentials.yaml && \
7285
cp .proxygen/settings-$(ENV).yaml ~/.proxygen/settings.yaml && \
73-
echo "Set up proxygen credentials for the '$(ENV)' environment"
86+
echo "Set up proxygen credentials for the APIM '$(ENV)' environment"
7487

7588
get-spec: # Get the most recent specification live in proxygen
7689
$(MAKE) setup-proxygen-credentials ENV=prod
7790
proxygen spec get
7891

7992
get-spec-uat: # Get the most recent specification live in proxygen
80-
$(MAKE) setup-proxygen-credentials ENV=ptl
93+
$(MAKE) setup-proxygen-credentials ENV=prod
8194
proxygen spec get --uat
8295

8396
publish-spec: # Publish the specification to proxygen
8497
$(MAKE) setup-proxygen-credentials ENV=prod
8598
proxygen spec publish build/specification/prod/eligibility-signposting-api.yaml
8699

87100
publish-spec-uat: # Publish the specification to proxygen
88-
$(MAKE) setup-proxygen-credentials ENV=ptl
101+
$(MAKE) setup-proxygen-credentials ENV=prod
89102
proxygen spec publish build/specification/preprod/eligibility-signposting-api.yaml --uat
90103

91104
delete-spec: # Delete the specification from proxygen
92105
$(MAKE) setup-proxygen-credentials ENV=prod
93106
proxygen spec delete
94107

95108
delete-spec-uat: # Delete the specification from proxygen
96-
$(MAKE) setup-proxygen-credentials ENV=ptl
109+
$(MAKE) setup-proxygen-credentials ENV=prod
97110
proxygen spec delete --uat
98111

99112
#####################

scripts/check-aws-account.sh

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,19 @@ set -e
44

55
APIM_ENV_NAME="$1"
66

7-
# Map APIM environment names to AWS account ID and environment name
8-
case "$APIM_ENV_NAME" in
9-
dev)
10-
AWS_ENV_NAME="dev"
11-
EXPECTED_ACCOUNT="448049830832"
12-
;;
13-
ptl)
14-
AWS_ENV_NAME="preprod" # Called 'preprod' in AWS and `ptl` in APIM
15-
EXPECTED_ACCOUNT="203918864209"
16-
;;
17-
prod)
18-
AWS_ENV_NAME="prod"
19-
EXPECTED_ACCOUNT="476114145616"
20-
;;
21-
*)
22-
echo "Unknown APIM environment: $APIM_ENV_NAME"
23-
exit 1
24-
;;
25-
esac
7+
# Expected AWS account for dev environment
8+
EXPECTED_ACCOUNT="448049830832"
269

2710
# Read the currently authenticated AWS account
2811
CURRENT_ACCOUNT=$(aws sts get-caller-identity --query "Account" --output text)
2912

3013
# Compare the current account with the expected account
3114
if [ "$CURRENT_ACCOUNT" != "$EXPECTED_ACCOUNT" ]; then
3215
echo "AWS account mismatch!"
33-
echo "The expected mapping for the argument 'ENV=$APIM_ENV_NAME' is AWS '$AWS_ENV_NAME' account $EXPECTED_ACCOUNT, but the current AWS account is $CURRENT_ACCOUNT."
16+
echo "The expected login is AWS '$APIM_ENV_NAME' account $EXPECTED_ACCOUNT, but the current logged in AWS account is $CURRENT_ACCOUNT."
3417
echo "Please switch to the correct AWS account and try again."
3518
echo "Exiting script..."
3619
exit 1
3720
fi
3821

39-
echo "Active login to AWS '$AWS_ENV_NAME' account $CURRENT_ACCOUNT verified."
22+
echo "Active login to AWS '$APIM_ENV_NAME' account $CURRENT_ACCOUNT verified."

0 commit comments

Comments
 (0)