Skip to content

Commit 070bbf4

Browse files
authored
Merge pull request #17 from jenny-curry/assignment-updates
Assignment updates
2 parents b203100 + aee6c98 commit 070bbf4

13 files changed

Lines changed: 1121 additions & 195 deletions
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Terraform Deploy to Azure
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
action:
7+
description: 'Terraform action to perform'
8+
required: true
9+
default: 'plan'
10+
type: choice
11+
options:
12+
- plan
13+
- apply
14+
- destroy
15+
push:
16+
branches:
17+
- main
18+
paths:
19+
- 'Terraform/**'
20+
- '.github/workflows/terraform-deploy.yml'
21+
pull_request:
22+
branches:
23+
- main
24+
paths:
25+
- 'Terraform/**'
26+
27+
permissions:
28+
id-token: write
29+
contents: read
30+
pull-requests: write
31+
32+
env:
33+
TF_VERSION: '1.5.0'
34+
WORKING_DIR: './Terraform'
35+
# Terraform Backend Configuration
36+
BACKEND_RESOURCE_GROUP: ${{ vars.TF_STATE_RESOURCE_GROUP }}
37+
BACKEND_STORAGE_ACCOUNT: ${{ vars.TF_STATE_STORAGE_ACCOUNT }}
38+
BACKEND_CONTAINER: ${{ vars.TF_STATE_CONTAINER }}
39+
BACKEND_KEY: ${{ vars.TF_STATE_KEY }}
40+
# Azure Auth
41+
ARM_CLIENT_ID: ${{ vars.CLIENT_ID }}
42+
ARM_SUBSCRIPTION_ID: ${{ vars.SUBSCRIPTION_ID }}
43+
ARM_TENANT_ID: ${{ vars.TENANT_ID }}
44+
ARM_USE_OIDC: true
45+
# Terraform Variables
46+
TF_VAR_resource_group_name: 'rg-vm-test1'
47+
TF_VAR_location: 'eastus'
48+
TF_VAR_function_app_name: fn-test-2026
49+
TF_VAR_logic_app_name: lg-test-2026
50+
TF_VAR_storage_account_name: ewutest2026
51+
TF_VAR_container_app_name: ca-test-2026
52+
TF_VAR_environment_name: development
53+
54+
jobs:
55+
terraform-plan:
56+
name: Terraform Plan
57+
runs-on: ubuntu-latest
58+
if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'plan')
59+
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Terraform
65+
uses: hashicorp/setup-terraform@v3
66+
with:
67+
terraform_version: ${{ env.TF_VERSION }}
68+
69+
- name: Azure Login with OIDC
70+
uses: azure/login@v1
71+
with:
72+
client-id: ${{ vars.CLIENT_ID }}
73+
tenant-id: ${{ vars.TENANT_ID }}
74+
subscription-id: ${{ vars.SUBSCRIPTION_ID }}
75+
76+
- name: Terraform Init
77+
working-directory: ${{ env.WORKING_DIR }}
78+
run: |
79+
terraform init \
80+
-backend-config="resource_group_name=${{ env.BACKEND_RESOURCE_GROUP }}" \
81+
-backend-config="storage_account_name=${{ env.BACKEND_STORAGE_ACCOUNT }}" \
82+
-backend-config="container_name=${{ env.BACKEND_CONTAINER }}" \
83+
-backend-config="key=${{ env.BACKEND_KEY }}"
84+
85+
- name: Terraform Format Check
86+
working-directory: ${{ env.WORKING_DIR }}
87+
run: terraform fmt -check -recursive
88+
continue-on-error: true
89+
90+
- name: Terraform Validate
91+
working-directory: ${{ env.WORKING_DIR }}
92+
run: terraform validate
93+
94+
- name: Terraform Plan
95+
working-directory: ${{ env.WORKING_DIR }}
96+
run: terraform plan
97+
98+
terraform-apply:
99+
name: Terraform Apply
100+
runs-on: ubuntu-latest
101+
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'apply')
102+
environment: production
103+
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v4
107+
108+
- name: Setup Terraform
109+
uses: hashicorp/setup-terraform@v3
110+
with:
111+
terraform_version: ${{ env.TF_VERSION }}
112+
113+
- name: Azure Login with OIDC
114+
uses: azure/login@v1
115+
with:
116+
client-id: ${{ vars.CLIENT_ID }}
117+
tenant-id: ${{ vars.TENANT_ID }}
118+
subscription-id: ${{ vars.SUBSCRIPTION_ID }}
119+
120+
- name: Terraform Init
121+
working-directory: ${{ env.WORKING_DIR }}
122+
run: |
123+
terraform init \
124+
-backend-config="resource_group_name=${{ env.BACKEND_RESOURCE_GROUP }}" \
125+
-backend-config="storage_account_name=${{ env.BACKEND_STORAGE_ACCOUNT }}" \
126+
-backend-config="container_name=${{ env.BACKEND_CONTAINER }}" \
127+
-backend-config="key=${{ env.BACKEND_KEY }}"
128+
129+
- name: Terraform Apply
130+
working-directory: ${{ env.WORKING_DIR }}
131+
run: terraform apply -auto-approve
132+
133+
- name: Display Deployment URLs
134+
working-directory: ${{ env.WORKING_DIR }}
135+
run: |
136+
echo "## Deployment Complete! 🚀" >> $GITHUB_STEP_SUMMARY
137+
echo "" >> $GITHUB_STEP_SUMMARY
138+
echo "### Deployed Resources:" >> $GITHUB_STEP_SUMMARY
139+
echo "- **Container App:** $(terraform output -raw container_app_url)" >> $GITHUB_STEP_SUMMARY
140+
echo "- **Function App:** $(terraform output -raw function_app_url)" >> $GITHUB_STEP_SUMMARY
141+
echo "- **Logic App:** $(terraform output -raw logic_app_url)" >> $GITHUB_STEP_SUMMARY
142+
echo "- **Resource Group:** $(terraform output -raw resource_group_name)" >> $GITHUB_STEP_SUMMARY
143+
144+
terraform-destroy:
145+
name: Terraform Destroy
146+
runs-on: ubuntu-latest
147+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'destroy'
148+
environment: destroy
149+
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v4
153+
154+
- name: Setup Terraform
155+
uses: hashicorp/setup-terraform@v3
156+
with:
157+
terraform_version: ${{ env.TF_VERSION }}
158+
159+
- name: Azure Login with OIDC
160+
uses: azure/login@v1
161+
with:
162+
client-id: ${{ vars.CLIENT_ID }}
163+
tenant-id: ${{ vars.TENANT_ID }}
164+
subscription-id: ${{ vars.SUBSCRIPTION_ID }}
165+
166+
- name: Terraform Init
167+
working-directory: ${{ env.WORKING_DIR }}
168+
run: |
169+
terraform init \
170+
-backend-config="resource_group_name=${{ env.BACKEND_RESOURCE_GROUP }}" \
171+
-backend-config="storage_account_name=${{ env.BACKEND_STORAGE_ACCOUNT }}" \
172+
-backend-config="container_name=${{ env.BACKEND_CONTAINER }}" \
173+
-backend-config="key=${{ env.BACKEND_KEY }}"
174+
175+
- name: Terraform Destroy
176+
working-directory: ${{ env.WORKING_DIR }}
177+
run: terraform destroy -auto-approve

Assignment2.md

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# EWU-CSCD396-2023-Fall
22

3-
## Assignment 2 - DRAFT!!!
3+
## Assignment 2
44

55
The purpose of this assignment is to solidify your learning of:
66

77
- Build and deploying containers
88
- Terraform IaC
9-
- Fnctions and Logic Apps
10-
- Messaging and Eventing
119

1210
## Prerequisites
1311

14-
- Install VSCode Extension 'Azure App Service'
12+
- All CLI tools used in doc/containers.md such as dotnet, docker, etc.
1513

1614
## Instructions
1715

@@ -25,46 +23,23 @@ Complete the following Tutorials and do not clean up resources until assignment
2523
{https://learn.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore?tabs=net70&pivots=development-environment-cli}
2624
Note: Deploy application code using az cli, not the VSCode extension
2725

28-
- Web App Created ❌✅
29-
(You can use the below steps to publish your app OR use the 'az webapp up' command in the above tutorial)
26+
- Container App Created ❌✅
27+
(You can use the below steps to publish your app)
3028

31-
- Run command from your terminal 'dotnet publish SampleApp/MyFirstAzureWebApp'. This builds the application and files are genearted in SampleApp/MyFirstAzureWebApp/bin/Debug/net7.0/publish folder
32-
- Zip the items in your created publish folder
33-
- Use 'az webapp deploy' command to deploy your zip file to the application
29+
- Create a new app using dotnet new command
30+
- See docs/containers.md for how to create and deploy an image of your new app code to azure container registry
3431

35-
- Url Accessible ❌✅
32+
- Create a terraform main.tf and variables.tf files within a terraform folder. These files should contain relevant HCL for deploying a container app. ❌✅
33+
- Use a variable for the container image name so that your workflow must pass this value into the terraform apply ❌✅
34+
- Create a workflow that deploys your container app with Terraform using the init, plan, and apply commands adn passes your container image name into the apply ❌✅
3635

37-
2. Create and deploy an Auzre Function Bound to Service Bus. The function should write messages received to a storage account
36+
- Url Accessible (and working) ❌✅
37+
- Successful Workflow Run to Deploy Infrastructure ❌✅
3838

39-
{https://learn.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-storage?tabs=azure-cli}
4039

41-
- Enabled Managed Identity on Web App ❌✅
42-
- Created Storage Account ❌✅
43-
- Web App Granted Access to Storage Account ❌✅
44-
45-
3. Add a feature to the web app to write a message to the Service Bus from step 2. Ideally this ia a text box for the message and a button to submit the message to the bus. You can use the Azure SDK for .NET to send messages to the bus from your web app.
46-
47-
48-
49-
50-
4. Create a PowerShell script called Assignment2.ps1 on your branch within the Assignment2 folder ❌✅
51-
52-
- Copy the following text into your PowerShell script and fill in your specific values for the variables
53-
```
54-
$SubscriptionId = ""
55-
$ResourceGroup = ""
56-
$WebAppName = ""
57-
$WebAppUrl = ""
58-
$KeyVault = ""
59-
$SecretName = ""
60-
$StorageAccount = ""
61-
```
62-
- You can test if your assignment will pass by running the PS script at Scripts/Assignment2Grading.ps1. Run your Assignment2.ps1 script to set local variables first.
63-
64-
5. Please add jcurry9@ewu.edu as a contributor to your subscription, otherwise grading will not be possible.
40+
4. Please add jcurry9@ewu.edu as a contributor to your subscription, otherwise grading will not be possible.
6541

6642

6743
## Extra Credit
6844

69-
- Have the web app write the message to an Azure SQL Table in addition to the message bus
70-
-
45+

Assignment3.md

Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,45 @@
11
# EWU-CSCD396-2023-Fall
22

3-
## Assignment 3
3+
## Assignment 3 - DRAFT!!!
44

55
The purpose of this assignment is to solidify your learning of:
66

7-
- Virtual Machines
8-
- Container Registry
9-
- Event Grid
10-
- Configuration of Event Grid to Subscribe to Container Registry Events
11-
- Using Azure PowerShell
12-
- Azure Container Instances
13-
- Event Hub
7+
- Build and deploying containers
8+
- Terraform IaC
9+
- Fnctions and Logic Apps
10+
- Messaging and Eventing
1411

1512
## Prerequisites
1613

17-
Please add jcurry9@ewu.edu as a contributor to your subscription, otherwise grading will not be possible.
14+
- Install VSCode Extension 'Azure App Service'
1815

1916
## Instructions
2017

21-
Complete the following Tutorials and do not clean up resources until assignment is graded.
22-
23-
1. Create Virtual Machine
24-
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-manage-vm?source=recommendations
25-
26-
- Virtual Machine Created ❌✅
27-
28-
2. Create Container Registry
29-
Note: Be sure you have docker desktop installed and running
30-
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-powershell
31-
32-
- Container Registry Created ❌✅
33-
- Image tagged 'hello-word:v1' is pushed to container registy ❌✅
18+
- All cloud infrastructure should be built with Terraform. Terraform State should be maintained in a Storage Account
19+
- All services should be deployed through a GitHub Action workflow
3420

35-
3. Create an Event Grid and Send Container Registry Events (Event Grid System Topic)
36-
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-event-grid-quickstart
37-
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-event-grid-quickstart#subscribe-to-registry-events
38-
39-
40-
- Event Grid Web Viewer Endpoint Available ❌✅
41-
- Subscribe Event Grid to Container Registry Events to Create an Event Grid System Topic ❌✅
42-
43-
- New Image Version Pushed to Container Registry from Step 2 ❌✅
44-
- Event Grid Subscription is Configured to Send Events to Event Viewer Web Endpoint❌✅
21+
Complete the following Tutorials and do not clean up resources until assignment is graded.
4522

46-
4. Create a container instance
47-
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-quickstart
23+
1. Create and deploy an Azure Function Bound to Service Bus. The function should write messages received to a storage account
4824

49-
- Container instance created ❌✅
25+
{https://learn.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-storage?tabs=azure-cli}
5026

51-
5. Create Event Hub
52-
https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-quickstart-powershell
27+
- Enabled Managed Identity on the function app ❌✅
28+
- Create Storage Account ❌✅
29+
- Function App Identity Granted Access to Storage Account ❌✅
5330

54-
- Event Hub Namespace Created ❌✅
55-
- Event Hub Created ❌✅
56-
- Events have been sent to your Event Hub (Submit a screenshot in your PR of Events that have been sent to your Event Hub) ❌✅
57-
https://learn.microsoft.com/en-us/azure/event-hubs/send-and-receive-events-using-data-generator
58-
[Screenshot Example](https://learn.microsoft.com/en-us/azure/event-hubs/send-and-receive-events-using-data-generator#view-events-using-event-hubs-data-generator)
31+
2. Add a feature to the container app to write a message to the Service Bus from step 2. Ideally this ia a text box for the message and a button to submit the message to the bus. You can use the Azure SDK for .NET to send messages to the bus from your container app.
5932

60-
6. Create a PowerShell script called Assignment3.ps1 on your branch within the Assignment3 folder ❌✅
33+
- Add an identity to the container app (by updating your terraform configuration) ❌✅
34+
- Assign the container app identity adequate permissions on your service bus to send messages. ❌✅
35+
- Can I enter a message on your site and see the message appear in your storage account ❌✅
6136

62-
- Copy the following text into your PowerShell script and fill in your specific values for the variables
63-
```
64-
$SubscriptionId = ""
65-
$ResourceGroup = ""
66-
$EventGridAppUrl = ""
67-
$VirtualMachineName = ""
68-
$ContainerRegistryName = ""
69-
$ContainerRegistryPassword = ""
70-
$EventHubNamespaceName = ""
71-
$EventHubName = ""
72-
$EventGridSystemTopicName = ""
73-
$ContainerGroupName = ""
74-
```
7537

7638

77-
## Script Grading
78-
You can test if your assignment will pass by running the PS script at Scripts/Assignment3Grading.ps1. Run your Assignment3.ps1 script to set local variables first.
39+
4. Please add jcurry9@ewu.edu as a contributor to your subscription, otherwise grading will not be possible.
7940

80-
Be sure to install the Az Powershell modules that are listed as dependencies
8141

8242
## Extra Credit
8343

84-
- Create a custom image from your virtual machine named 'vm-image:v1" and push the image to your container registry. ❌✅
85-
https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images
44+
- Have the web app write the message to an Azure SQL Table in addition to the message bus
45+
-

0 commit comments

Comments
 (0)