Skip to content

Commit

Permalink
Merge pull request #2 from stemaMSFT/master
Browse files Browse the repository at this point in the history
Fixing YAML (possibly)
  • Loading branch information
stemaMSFT authored Oct 31, 2023
2 parents 32ba57b + 29b2426 commit 7f5eded
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 46 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ jobs:
defaults:
run:
shell: bash
working-directory: ./main

steps:
- name: Azure Login
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# - name: Azure Login
# uses: azure/actions/login@v1
# with:
# creds: ${{ secrets.AZURE_CREDENTIALS }}

# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

# Install the preferred version of Terraform CLI
- name: Setup Terraform
Expand All @@ -41,10 +40,10 @@ jobs:
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
STORAGE_ACCOUNT: ${{ secrets.STORAGE_ACCOUNT }}
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
run: terraform init -backend-config="storage_account_name=$STORAGE_ACCOUNT" -backend-config="container_name=$CONTAINER_NAME" -backend-config="resource_group_name=$RESOURCE_GROUP"
# RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }}
# STORAGE_ACCOUNT: ${{ secrets.STORAGE_ACCOUNT }}
# CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
run: terraform init #-backend-config="storage_account_name=$STORAGE_ACCOUNT" -backend-config="container_name=$CONTAINER_NAME" -backend-config="resource_group_name=$RESOURCE_GROUP"


# Run a terraform plan for pull requests only
Expand All @@ -56,17 +55,15 @@ jobs:
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
if: github.event_name == 'pull_request'
run: terraform plan -no-color
run: terraform plan #-no-color

# Add a comment to pull requests with plan results
- name: add-plan-comment
- uses: actions/github-script@v6
id: comment
uses: actions/github-script@v3
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
Expand All @@ -81,7 +78,7 @@ jobs:

*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;

github.issues.createComment({
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
67 changes: 42 additions & 25 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
resource "azurerm_resource_group" "qs101" {
name = "rg-qs101"
location = "westus2"
# __generated__ by Terraform from "/subscriptions/6e4d4d41-20a6-4801-8eec-c769d870e333/resourceGroups/tfstate"
resource "azapi_resource" "example" {
body = "{\"properties\":{}}"
ignore_casing = false
ignore_missing_property = true
location = "eastus"
locks = null
name = "tfstate"
parent_id = "/subscriptions/6e4d4d41-20a6-4801-8eec-c769d870e333"
removing_special_chars = false
response_export_values = null
schema_validation_enabled = true
tags = {}
type = "Microsoft.Resources/resourceGroups@2022-09-01"
timeouts {
create = null
delete = null
read = null
update = null
}
}
# Provision a Lab Service Account and a Lab that are in public preview
resource "azapi_resource" "qs101-account" {
type = "Microsoft.LabServices/labaccounts@2018-10-15"
name = "qs101LabAccount"
parent_id = azurerm_resource_group.qs101.id
# # Provision a Lab Service Account and a Lab that are in public preview
# resource "azapi_resource" "qs101-account" {
# type = "Microsoft.LabServices/labaccounts@2018-10-15"
# name = "qs101LabAccount"
# parent_id = azurerm_resource_group.qs101.id

body = jsonencode({
properties = {
enabledRegionSelection = false
}
})
}
# body = jsonencode({
# properties = {
# enabledRegionSelection = false
# }
# })
# }

resource "azapi_resource" "qs101-lab" {
type = "Microsoft.LabServices/labaccounts/labs@2018-10-15"
name = "qs101Lab"
parent_id = azapi_resource.qs101-account.id
# resource "azapi_resource" "qs101-lab" {
# type = "Microsoft.LabServices/labaccounts/labs@2018-10-15"
# name = "qs101Lab"
# parent_id = azapi_resource.qs101-account.id

body = jsonencode({
properties = {
maxUsersInLab = 10
userAccessMode = "Restricted"
}
})
}
# body = jsonencode({
# properties = {
# maxUsersInLab = 10
# userAccessMode = "Restricted"
# }
# })
# }
12 changes: 6 additions & 6 deletions providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ terraform {
source = "hashicorp/random"
}
}
backend "azurerm" {
resource_group_name = "tfstate"
storage_account_name = "tfstate8q1ou"
container_name = "tfstate"
key = "terraform.tfstate"
}
# backend "azurerm" {
# resource_group_name = "tfstate"
# storage_account_name = "tfstate8q1ou"
# container_name = "tfstate"
# key = "terraform.tfstate"
# }
}

provider "azapi" {
Expand Down

0 comments on commit 7f5eded

Please sign in to comment.