Skip to content

Commit cdbfc3f

Browse files
committed
datestamp and maybe final indenting fixes
1 parent 54371fa commit cdbfc3f

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

_source/_posts/2025-01-09-terraform-powershell-lab.md _source/_posts/2025-01-21-terraform-powershell-lab.md

+51-51
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ You will save a private key alongside your code to simplify the lab. In producti
8888

8989
4. On your computer, paste the key into a file and save it as `key.pem`
9090

91-
**Important:** The key is saved locally to simplify the lab. You should save the key to an appropriate secrets management solution when working with production environments. If you do not have secrets management, [this blog post](/blog/2024/10/11/terraform-ci-cd) shares one way to set it up.
91+
**Important:** The key is saved locally to simplify the lab. You should save the key to an appropriate secrets management solution when working with production environments. If you do not have secrets management, [this blog post](/blog/2024/10/11/terraform-ci-cd) shares one way to set it up.
9292

9393
5. Complete the configuration steps.
9494

@@ -117,30 +117,30 @@ You will save a private key alongside your code to simplify the lab. In producti
117117

118118
8. In your VM, create the file `main.tf`:
119119

120-
```hcl
121-
terraform {
122-
required_providers {
123-
okta = {
124-
source = "okta/okta"
125-
}
126-
}
127-
}
128-
129-
variable "org_id" {
130-
default = "ORGID"
131-
}
132-
133-
provider "okta" {
134-
org_name = var.org_id
135-
base_url = "oktapreview.com"
136-
client_id = "CLIENTID"
137-
scopes = ["okta.apps.manage", "okta.appGrants.manage",
138-
"okta.oauthIntegrations.manage", "okta.users.manage",
139-
"okta.policies.read"]
140-
private_key = file("key.pem")
141-
}
142-
143-
```
120+
```hcl
121+
terraform {
122+
required_providers {
123+
okta = {
124+
source = "okta/okta"
125+
}
126+
}
127+
}
128+
129+
variable "org_id" {
130+
default = "ORGID"
131+
}
132+
133+
provider "okta" {
134+
org_name = var.org_id
135+
base_url = "oktapreview.com"
136+
client_id = "CLIENTID"
137+
scopes = ["okta.apps.manage", "okta.appGrants.manage",
138+
"okta.oauthIntegrations.manage", "okta.users.manage",
139+
"okta.policies.read"]
140+
private_key = file("key.pem")
141+
}
142+
143+
```
144144
9. In your `main.tf` file, replace `ORGID` with the subdomain for your Okta org.
145145

146146
**Note:** The subdomain is between `https://` and `.oktapreview.com`. In the example below, the subdomain is `oktaice0000000`.
@@ -174,19 +174,19 @@ You can access PowerShell 7 by launching it from the shortcut generated during i
174174
## Configure a PowerShell Application using Terraform
175175
1. Add the following to your `main.tf` file:
176176
177-
```hcl
178-
resource "okta_app_oauth" "ps" {
179-
180-
grant_types = ["authorization_code",
181-
"urn:ietf:params:oauth:grant-type:device_code"]
182-
label = "PowerShell"
183-
response_types = ["code"]
184-
type = "native"
185-
redirect_uris = ["com.oktapreview.${var.org_id}:/callback"]
186-
token_endpoint_auth_method = "none"
187-
implicit_assignment = true
188-
issuer_mode = "DYNAMIC"
189-
}
177+
```hcl
178+
resource "okta_app_oauth" "ps" {
179+
180+
grant_types = ["authorization_code",
181+
"urn:ietf:params:oauth:grant-type:device_code"]
182+
label = "PowerShell"
183+
response_types = ["code"]
184+
type = "native"
185+
redirect_uris = ["com.oktapreview.${var.org_id}:/callback"]
186+
token_endpoint_auth_method = "none"
187+
implicit_assignment = true
188+
issuer_mode = "DYNAMIC"
189+
}
190190
191191
resource "okta_app_oauth_api_scope" "ps-scopes" {
192192
app_id = okta_app_oauth.ps.id
@@ -202,23 +202,23 @@ You can access PowerShell 7 by launching it from the shortcut generated during i
202202
4. Wait for the `terraform apply` to complete.
203203
5. From the `Creation complete after` output, copy the value of the `okta_app_oauth` id.
204204

205-
**Note:** PowerShell and Terraform now have separate applications in your Okta organization. The PowerShell application's ID can also be found in the Okta admin console under Applications -> Applications.
205+
**Note:** PowerShell and Terraform now have separate applications in your Okta organization. The PowerShell application's ID can also be found in the Okta admin console under Applications -> Applications.
206206

207207
6. In PowerShell, run these commands:
208208

209-
**Note:** Replace the {yourOktaDomain} with the entire domain for your Okta org. For example, `oktaice0000000.oktapreview.com`. Replace the ID with the value you copied above.
209+
**Note:** Replace the {yourOktaDomain} with the entire domain for your Okta org. For example, `oktaice0000000.oktapreview.com`. Replace the ID with the value you copied above.
210210

211-
```powershell
212-
$Configuration = Get-OktaConfiguration
213-
$Configuration.BaseUrl = "https://{yourOktaDomain}"
214-
$Configuration.ClientId = "id"
215-
$Configuration.Scope = "okta.apps.read okta.domains.read okta.groups.read okta.logs.read okta.oauthIntegrations.read okta.orgs.read okta.userTypes.read okta.users.read"
216-
Invoke-OktaEstablishAccessToken
217-
```
218-
219-
7. The `Invoke-OktaEstablishAccessToken` command displays a URL. Open the link in a web browser.
220-
8. Authenticate to your Okta Training Org when prompted.
221-
9. In your PowerShell session, run the command `Invoke-OktaListApplications`
211+
```powershell
212+
$Configuration = Get-OktaConfiguration
213+
$Configuration.BaseUrl = "https://{yourOktaDomain}"
214+
$Configuration.ClientId = "id"
215+
$Configuration.Scope = "okta.apps.read okta.domains.read okta.groups.read okta.logs.read okta.oauthIntegrations.read okta.orgs.read okta.userTypes.read okta.users.read"
216+
Invoke-OktaEstablishAccessToken
217+
```
218+
219+
7. The `Invoke-OktaEstablishAccessToken` command displays a URL. Open the link in a web browser.
220+
8. Authenticate to your Okta Training Org when prompted.
221+
9. In your PowerShell session, run the command `Invoke-OktaListApplications`
222222

223223
## Extra Credit
224224
You have set up the PowerShell application with various scopes. What interesting information about your organization can you retrieve using these scopes? Will these scopes allow you to make any changes to the Okta organization? Try some PowerShell commands to create or destroy resources and see what happens!

0 commit comments

Comments
 (0)