Skip to content

Commit b7bc9e7

Browse files
committed
change deploy certificate to use az nginx cli
move from using ARM deployment templates to `az nginx deployment certificate update`. This change prevents the need for contributor level permissions on the resource group of the NGINXaaS deployment.
1 parent 3d6ef3f commit b7bc9e7

File tree

3 files changed

+12
-97
lines changed

3 files changed

+12
-97
lines changed

github-action/action.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ inputs:
1010
nginx-deployment-name:
1111
description: "The name of the NGINXaaS for Azure deployment."
1212
required: true
13-
nginx-deployment-location:
14-
description: "The location where the NGINX deployment is located. Example westcentralus"
15-
required: false
16-
deprecationMessage: "This field is not in use and will be removed in a future release. Consider dropping it from your Github Action configuration."
1713
nginx-config-directory-path:
1814
description: 'The NGINX configuration directory path relative to the root of the Git repository, example: "config/".'
1915
required: false
@@ -40,8 +36,8 @@ runs:
4036
using: "composite"
4137
steps:
4238
- name: "Synchronize NGINX certificate(s) from the Git repository to an NGINXaaS for Azure deployment"
43-
run: ${{github.action_path}}/src/deploy-certificate.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --nginx_resource_location=${{ inputs.nginx-deployment-location }} --certificates=${{ toJSON(inputs.nginx-certificates) }} --debug=${{ inputs.debug }}
44-
if: ${{ inputs.nginx-deployment-location != '' && inputs.nginx-certificates != '' }}
39+
run: ${{github.action_path}}/src/deploy-certificate.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --certificates=${{ toJSON(inputs.nginx-certificates) }} --debug=${{ inputs.debug }}
40+
if: ${{ inputs.nginx-certificates != '' }}
4541
shell: bash
4642
- name: "Synchronize NGINX configuration from the Git repository to an NGINXaaS for Azure deployment"
4743
run: ${{github.action_path}}/src/deploy-config.sh --subscription_id=${{ inputs.subscription-id }} --resource_group_name=${{ inputs.resource-group-name }} --nginx_deployment_name=${{ inputs.nginx-deployment-name }} --config_dir_path=${{ inputs.nginx-config-directory-path }} --root_config_file=${{ inputs.nginx-root-config-file }} --transformed_config_dir_path=${{ inputs.transformed-nginx-config-directory-path }} --debug=${{ inputs.debug }}

github-action/src/deploy-certificate.sh

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ case $i in
1717
nginx_deployment_name="${i#*=}"
1818
shift
1919
;;
20-
--nginx_resource_location=*)
21-
nginx_resource_location="${i#*=}"
22-
shift
23-
;;
2420
--certificates=*)
2521
certificates="${i#*=}"
2622
shift
@@ -51,26 +47,12 @@ then
5147
echo "Please set 'nginx-deployment-name' ..."
5248
exit 1
5349
fi
54-
if [[ ! -v nginx_resource_location ]];
55-
then
56-
echo "Please set 'nginx-resource-location' ..."
57-
exit 1
58-
fi
5950
if [[ ! -v certificates ]];
6051
then
6152
echo "Please set 'nginx-certificates' ..."
6253
exit 1
6354
fi
6455

65-
arm_template_file="nginx-for-azure-certificate-template.json"
66-
67-
#get the ARM template file
68-
wget -O "$arm_template_file" https://raw.githubusercontent.com/nginxinc/nginx-for-azure-deploy-action/a69d33feaa1a8a012ec44c138ca78c6ec4db9f29/src/nginx-for-azure-certificate-template.json
69-
echo "Downloaded the ARM template for synchronizing NGINX certificate."
70-
71-
cat "$arm_template_file"
72-
echo ""
73-
7456
az account set -s "$subscription_id" --verbose
7557

7658
count=$(echo "$certificates" | jq '. | length')
@@ -104,41 +86,33 @@ do
10486
do_nginx_arm_deployment=0
10587
fi
10688

107-
uuid="$(cat /proc/sys/kernel/random/uuid)"
108-
template_file="template-$uuid.json"
109-
template_deployment_name="${nginx_deployment_name:0:20}-$uuid"
110-
111-
cp "$arm_template_file" "$template_file"
112-
11389
echo "Synchronizing NGINX certificate"
11490
echo "Subscription ID: $subscription_id"
11591
echo "Resource group name: $resource_group_name"
11692
echo "NGINXaaS for Azure deployment name: $nginx_deployment_name"
117-
echo "NGINXaaS for Azure Location: $nginx_resource_location"
118-
echo "ARM template deployment name: $template_deployment_name"
11993
echo ""
12094
echo "NGINXaaS for Azure cert name: $nginx_cert_name"
12195
echo "NGINXaaS for Azure cert file location: $nginx_cert_file"
12296
echo "NGINXaaS for Azure key file location: $nginx_key_file"
12397
echo ""
12498

99+
echo "Installing the az nginx extension if not already installed."
100+
az extension add --name nginx --allow-preview true
101+
125102
if [ $do_nginx_arm_deployment -eq 1 ]
126103
then
127104
az_cmd=(
128105
"az"
106+
"nginx"
129107
"deployment"
130-
"group"
108+
"certificate"
131109
"create"
132-
"--name" "$template_deployment_name"
133110
"--resource-group" "$resource_group_name"
134-
"--template-file" "$template_file"
135-
"--parameters"
136-
"name=$nginx_cert_name"
137-
"location=$nginx_resource_location"
138-
"nginxDeploymentName=$nginx_deployment_name"
139-
"certificateVirtualPath=$nginx_cert_file"
140-
"keyVirtualPath=$nginx_key_file"
141-
"keyVaultSecretID=$keyvault_secret"
111+
"--certificate-name" "$nginx_cert_name"
112+
"--deployment-name" "$nginx_deployment_name"
113+
"--certificate-path" "$nginx_cert_file"
114+
"--key-path" "$nginx_key_file"
115+
"--key-vault-secret-id" "$keyvault_secret"
142116
"--verbose"
143117
)
144118
if [[ "$debug" == true ]]; then

github-action/src/nginx-for-azure-certificate-template.json

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)