Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fbeltrao/az-func-gh-deployment
Testing Azure Function deployments
https://github.com/fbeltrao/az-func-gh-deployment
Last synced: 3 days ago
JSON representation
Testing Azure Function deployments
- Host: GitHub
- URL: https://github.com/fbeltrao/az-func-gh-deployment
- Owner: fbeltrao
- License: mit
- Created: 2021-12-12T16:23:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-26T15:30:06.000Z (almost 3 years ago)
- Last Synced: 2023-03-08T20:22:44.048Z (over 1 year ago)
- Language: HCL
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Azure Function deployments with Terraform and GitHub Actions
Testing Azure Function deployments
## Testing locally
1. Install Terraform
1. Provide required variables
1. Initialize Terraform with custom state settings
1. Makes changes and apply## Install Terraform
TODO
## Provide required variables
To provide the required variable we can use environment variables or a variable file (.tfvars)
### Set values using environment variables
Create environment variables with `TF_VAR_` prefix. In PowerShell:
```plain
$env:TF_VAR_name_prefix=""
$env:TF_VAR_location=""
$env:TF_VAR_secret_1="my_secret_value_1"
$env:TF_VAR_secret_2="my_secret_value_2"
```### Set values using tfvars file
Create a tfvars file with contents:
```plain
name_prefix = ""
location = ""
secret_1 = "my_secret_value_1"
secret_2 = "my_secret_value_2"
```## Initialize Terraform with custom state settings
The resource group and the storage account must pre-exist. Ensure the storage account has a container named `deployments`
### Using environment variables
```plain
$env:TFStateResourceGroup=""
$env:TFStateStorageAccountName=""
terraform init -backend-config="resource_group_name=$env:TFStateResourceGroup" -backend-config="storage_account_name=$env:TFStateStorageAccountName"
```### Using configuration files
Create a .tfbackend file (recommended file extension) such as:
```plain
resource_group_name = ""
storage_account_name = ""
```Then initialize it:
```plain
terraform init -backend-config="stage.tfbackend"
``````plain
terraform init -backend-config="storage_account_name=$env:TFStateStorageAccountName" -backend-config="stage.tfbackend"
```### Makes changes and apply
To plan changes:
```plain
terraform plan
OR
terraform plan -var-file="my_file.tfvars"
```To apply changes:
```plain
terraform apply -auto-approve
```## Troubleshooting
### Error: Backend configuration changed
This error happens if already have a ./terraform folder and change the backend configuration. For development purposes deleting the `.terraform` folder and the `.terraform.lock.hcl` do the trick.