Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow public traffic to storage accounts #227

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deployment/bin/kv_add_ip
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

cidr=$(get_cidr_range)

echo "Adding IP $cidr to Key Vault firewall allow list..."
az keyvault network-rule add \
-g ${KEY_VAULT_RESOURCE_GROUP_NAME} \
-n ${KEY_VAULT_NAME} \
--ip-address $cidr \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none

# Also add the IP to the terraform state storage account
echo "Adding IP $cidr to Storage firewall allow list..."
az storage account network-rule add \
-g ${TFSTATE_SA_RG} \
-n ${TFSTATE_SA_NAME} \
--ip-address $cidr \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none

fi
9 changes: 9 additions & 0 deletions deployment/bin/kv_rmv_ip
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

cidr=$(get_cidr_range)

echo "Removing IP $cidr from Key Vault firewall allow list..."
az keyvault network-rule remove \
-g ${KEY_VAULT_RESOURCE_GROUP_NAME} \
-n ${KEY_VAULT_NAME} \
--ip-address $cidr \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none

echo "Removing IP $cidr from Storage firewall allow list..."
az storage account network-rule remove \
-g ${TFSTATE_SA_RG} \
-n ${TFSTATE_SA_NAME} \
--ip-address $cidr \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none

fi
2 changes: 2 additions & 0 deletions deployment/bin/lib
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function disable_shared_access_keys() {
--name ${SAK_STORAGE_ACCOUNT} \
--resource-group ${SAK_RESOURCE_GROUP} \
--allow-shared-key-access false \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none

if [ $? -ne 0 ]; then
Expand All @@ -168,6 +169,7 @@ function enable_shared_access_keys() {
--name ${SAK_STORAGE_ACCOUNT} \
--resource-group ${SAK_RESOURCE_GROUP} \
--allow-shared-key-access true \
--subscription ${ARM_SUBSCRIPTION_ID} \
--output none
done
}
4 changes: 4 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ services:
# Used to open KV firewall for accessing tf.secrets
- KEY_VAULT_NAME=pc-test-deploy-secrets
- KEY_VAULT_RESOURCE_GROUP_NAME=pc-test-manual-resources

# Used to open firewall to tfstate SA
- TFSTATE_SA_RG=pc-test-manual-resources
- TFSTATE_SA_NAME=pctesttfstate
working_dir: /opt/src/deployment
volumes:
- ../deployment:/opt/src/deployment
Expand Down
5 changes: 5 additions & 0 deletions deployment/terraform/resources/storage_account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ resource "azurerm_storage_account" "pc" {
min_tls_version = "TLS1_2"
allow_nested_items_to_be_public = false

network_rules {
default_action = "Deny"
virtual_network_subnet_ids = [azurerm_subnet.node_subnet.id, ]
}

# Disabling shared access keys breaks terraform's ability to do subsequent
# resource fetching during terraform plan. As a result, this property is
# ignored and managed outside of this apply session, via the deploy script.
Expand Down
Loading