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

Refactor: remove role assignment from Terraform #359

Merged
merged 4 commits into from
Oct 31, 2023
Merged
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
22 changes: 22 additions & 0 deletions docs/deployment/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The following things in Azure are managed outside of Terraform:
- Active Directory (users, groups, service principals, etc.)
- Service connections
- Configuration files, stored as blobs
- Role assignments

## Environments

Expand Down Expand Up @@ -136,3 +137,24 @@ In general, the steps that must be done manually before the pipeline can be run
- Create Terraform workspace for each environment
- Trigger a pipeline run to verify `plan` and `apply`
- Known chicken-and-egg problem: Terraform both creates the Key Vault and expects a secret within it, so will always fail on the first deploy. Add the Benefits slack email secret and re-run the pipeline.

Once the pipeline has run, there are a few more steps to be done manually in the Azure portal. These are related to configuring the service principal used for ETL:

- [Create the service principal](https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#app-registration-app-objects-and-service-principals)
- Give the ETL service principal access to the `prod` storage account created by the pipeline:
- Navigate to the storage account container
- Select **Access Control (IAM)**
- Select **Add**, then select **Add role assignment**
- In the **Role** tab, select `Storage Blob Data Contributor`
- In the **Members** tab, select `Select Members` and search for the ETL service principal. Add it to the role.
- Also in the **Members** tab, add a description of `This role assignment gives write access only for the path of the hashed data file.`
- In the **Conditions** tab, select **Add condition** and change the editor type to `Code`
- Add the following condition into the editor, filling in `<filename>` with the appropriate value:

```text
(
(
@Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:path] StringLike '<filename>'
)
)
```
1 change: 0 additions & 1 deletion terraform/mst/azure-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ variables:
TF_VAR_AGENCY_CARD: "mst-courtesy-cards"
TF_VAR_AGENCY_RESOURCE_GROUP_PREFIX: "courtesy-cards"
TF_VAR_AGENCY_STORAGE_ACCOUNT_PREFIX: "mstcceligibility"
TF_VAR_AGENCY_CARD_DATA_ETL_FILE: "velocity.csv"
16 changes: 0 additions & 16 deletions terraform/roles.tf

This file was deleted.

1 change: 0 additions & 1 deletion terraform/sbmtd/azure-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ variables:
TF_VAR_AGENCY_CARD: "sbmtd-mobility-pass"
TF_VAR_AGENCY_RESOURCE_GROUP_PREFIX: "sbmtd-mobility-pass"
TF_VAR_AGENCY_STORAGE_ACCOUNT_PREFIX: "sbmtdmobilitypass"
TF_VAR_AGENCY_CARD_DATA_ETL_FILE: "mobilitypass.csv"
10 changes: 0 additions & 10 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ variable "AGENCY_CARD" {
type = string
}

variable "AGENCY_CARD_DATA_ETL_APP_OBJECT_ID" {
description = "Object ID from the registered application for the Agency Card server ETL uploading: https://cloudsight.zendesk.com/hc/en-us/articles/360016785598-Azure-finding-your-service-principal-object-ID"
type = string
}

variable "AGENCY_CARD_DATA_ETL_FILE" {
description = "The name of the hashed data file that's uploaded to the storage account"
type = string
}

variable "AGENCY_RESOURCE_GROUP_PREFIX" {
description = "The prefix to the name of the resource group for each environment"
type = string
Expand Down