Skip to content

Create a terraform script to deploy application to Azure app service #1

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@ terraform apply
terraform destroy
```

#### Application Deployment (Azure)

To deploy the application to Azure App Service, follow these steps:

1. Create an Azure App Service Plan:

```bash
az appservice plan create --name myAppServicePlan --resource-group $TERRAGOAT_RESOURCE_GROUP --location $TF_VAR_region --sku B1 --is-linux
```

2. Create an Azure App Service:

```bash
az webapp create --resource-group $TERRAGOAT_RESOURCE_GROUP --plan myAppServicePlan --name myAppService --runtime "NODE|14-lts"
```

3. Configure the App Service to use a connection string:

```bash
az webapp config connection-string set --resource-group $TERRAGOAT_RESOURCE_GROUP --name myAppService --settings MyConnectionString="Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=myuser;Password=mypassword;Encrypt=true;Connection Timeout=30;" --connection-string-type SQLAzure
```

4. Deploy your application code to the App Service. You can use various methods such as FTP, Git, or Azure DevOps to deploy your code.

### GCP Setup

#### Installation (GCP)
Expand Down
21 changes: 21 additions & 0 deletions terraform/azure/app_service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,24 @@
}
}

resource "azurerm_app_service" "app-service3" {
app_service_plan_id = azurerm_app_service_plan.example.id
location = var.location
name = "terragoat-app-service-${var.environment}-deployment"
resource_group_name = azurerm_resource_group.example.name
https_only = true

site_config {
min_tls_version = "1.2"
}
Comment on lines +42 to +44

Check notice

Code scanning / Trivy

Web App uses the latest HTTP version Low

Artifact: terraform/azure/app_service.tf
Type: terraform
Vulnerability AVD-AZU-0005
Severity: LOW
Message: App service does not have HTTP/2 enabled.
Link: AVD-AZU-0005

auth_settings {
enabled = true
}

connection_string {
name = "MyConnectionString"
type = "SQLAzure"
value = "Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=myuser;Password=mypassword;Encrypt=true;Connection Timeout=30;"
}
}
Comment on lines +35 to +55

Check notice

Code scanning / Trivy

Web App accepts incoming client certificate Low

Artifact: terraform/azure/app_service.tf
Type: terraform
Vulnerability AVD-AZU-0001
Severity: LOW
Message: App service does not have client certificates enabled.
Link: AVD-AZU-0001
Comment on lines +35 to +55

Check notice

Code scanning / Trivy

Web App has registration with AD enabled Low

Artifact: terraform/azure/app_service.tf
Type: terraform
Vulnerability AVD-AZU-0002
Severity: LOW
Message: App service does not have an identity type.
Link: AVD-AZU-0002
Loading