Skip to content
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

🔄 Terraform changes from feat-gitignore #500

Merged
merged 12 commits into from
Sep 26, 2024
Merged
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
33 changes: 24 additions & 9 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Setup an account within terraform cloud if you havent already -
And create a new terraform cloud organization. Organizations are privately shared spaces for teams to collaborate on infrastructure.
![tfc-org](./media/screenshots/create-tfc-org.png)


- **Create Terraform Cloud Project**:
Create a new project in Terraform Cloud for your Jamf Pro infrastructure.
![tfc-project](./media/screenshots/create-tfc-project.png)
Expand Down Expand Up @@ -126,6 +127,8 @@ Each workspace holds a unique state for the correlating jamf pro environment.

f. Apply this variable set to all three Jamf Pro workspaces.

![tfc-variable-set](./media/screenshots/tfc-variable-set.png)

- **Configure Workspace-Specific Variables**:
For each workspace, set the following variables as `Terraform variable`:

Expand All @@ -141,17 +144,28 @@ Each workspace holds a unique state for the correlating jamf pro environment.

d. Mark sensitive variables (like passwords and secrets) as sensitive.

![tfc-workspace-vars](./media/screenshots/tfc-workspace-vars.png)

- **Access Controls**:
Set up appropriate access controls for each workspace:

a. Go to the "Team Access" section in each workspace's settings.
b. Assign the appropriate permissions to team members based on their roles and the environment.
c. Consider restricting access to production workspaces to a smaller group of trusted team members.

- **Generate Terraform Cloud API token**:
This token will be used by github actions to communicate with terraform cloud.

Within TFC go to account settings -> tokens -> generate an api token

Give this token a lifespan you are happy with and save it for later in use with github actions

![tfc-tokens](./media/screenshots/tfc-tokens.png)


3. **Configure Github Secrets**: Set up the following secrets in your GitHub repository settings:

- `TF_API_TOKEN`: Your Terraform Cloud API token for Terraform Cloud backend. this can be generated from the Terraform Cloud UI under account settings -> Tokens -> create api token.
- `TF_API_TOKEN`: Your Terraform Cloud API token for Terraform Cloud backend.
- `PAT_TOKEN`: Your GitHub Personal Access Token for branch management operations.

To set up the PAT_TOKEN:
Expand Down Expand Up @@ -204,14 +218,15 @@ These webhook URLs are used in the Send Notification workflow (send-notification
4. **Configure Terraform Cloud Secrets**:

Set up the following secrets in your Terraform Cloud workspace variable settings for each environment (Sandbox, Staging, Production):
- `JAMFPRO_INSTANCE_FQDN`: Your Jamf Pro instance URL. For example: `https://your-instance.jamfcloud.com`.
- `JAMFPRO_AUTH_METHOD`: Can be either `basic` or `oauth2`.
- `JAMFPRO_CLIENT_ID`: Your Jamf Pro client id when `JAMFPRO_AUTH_METHOD` is set to 'oauth2'.
- `JAMFPRO_CLIENT_SECRET`: Your Jamf Pro client secret when `JAMFPRO_AUTH_METHOD` is set to 'oauth2'.
- `JAMFPRO_BASIC_AUTH_USERNAME`: Your Jamf Pro username when `JAMFPRO_AUTH_METHOD` is set to 'basic'.
- `JAMFPRO_BASIC_AUTH_PASSWORD`: Your Jamf Pro user password when `JAMFPRO_AUTH_METHOD` is set to 'basic'.

Note: For Terraform Cloud, when setting variables you do not need to prefix your env vars with `TF_VAR_` as Terraform Cloud automatically does this for you. Additionally, ensure to select the variable category as `Terraform variable`, with the HCL tickbox unchecked.

- `JAMFPRO_INSTANCE_FQDN`: Your Jamf Pro instance URL. For example: `https://your-instance.jamfcloud.com`.
- `JAMFPRO_AUTH_METHOD`: Can be either `basic` or `oauth2`.
- `JAMFPRO_CLIENT_ID`: Your Jamf Pro client id when `JAMFPRO_AUTH_METHOD` is set to 'oauth2'.
- `JAMFPRO_CLIENT_SECRET`: Your Jamf Pro client secret when `JAMFPRO_AUTH_METHOD` is set to 'oauth2'.
- `JAMFPRO_BASIC_AUTH_USERNAME`: Your Jamf Pro username when `JAMFPRO_AUTH_METHOD` is set to 'basic'.
- `JAMFPRO_BASIC_AUTH_PASSWORD`: Your Jamf Pro user password when `JAMFPRO_AUTH_METHOD` is set to 'basic'.

Note: For Terraform Cloud, when setting variables you do not need to prefix your env vars with `TF_VAR_` as Terraform Cloud automatically does this for you. Additionally, ensure to select the variable category as `Terraform variable`, with the HCL tickbox unchecked.

5. **GitHub Repository-Level Setting**:

Expand Down
Binary file added docs/media/screenshots/tfc-tokens.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/screenshots/tfc-variable-set.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/screenshots/tfc-workspace-vars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 27 additions & 27 deletions workload/terraform/jamfpro/buildings.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@

resource "jamfpro_building" "jamfpro_building_001" {
name = "tf-demo-Apple-Park"
street_address1 = "The McIntosh Tree"
street_address2 = "One Apple Park Way"
city = "Cupertino"
state_province = "California"
zip_postal_code = "95014"
country = "The United States of America"
}
# resource "jamfpro_building" "jamfpro_building_001" {
# name = "tf-demo-Apple-Park"
# street_address1 = "The McIntosh Tree"
# street_address2 = "One Apple Park Way"
# city = "Cupertino"
# state_province = "California"
# zip_postal_code = "95014"
# country = "The United States of America"
# }

resource "jamfpro_building" "jamfpro_building_002" {
name = "tf-demo-jamf-headquarters"
street_address1 = "100 Washington Ave S"
street_address2 = "Suite 1100"
city = "Minneapolis"
state_province = "Minnesota"
zip_postal_code = "55401"
country = "The United States of America"
}
# resource "jamfpro_building" "jamfpro_building_002" {
# name = "tf-demo-jamf-headquarters"
# street_address1 = "100 Washington Ave S"
# street_address2 = "Suite 1100"
# city = "Minneapolis"
# state_province = "Minnesota"
# zip_postal_code = "55401"
# country = "The United States of America"
# }

resource "jamfpro_building" "jamfpro_building_003" {
name = "tf-demo-Apple-Battersea"
street_address1 = "Ground Floor, Turbine Hall A, Circus Rd W, Nine Elms"
street_address2 = "Suite 1100"
city = "London"
state_province = "London"
zip_postal_code = "SW11 8AL"
country = "United Kingdom"
}
# resource "jamfpro_building" "jamfpro_building_003" {
# name = "tf-demo-Apple-Battersea"
# street_address1 = "Ground Floor, Turbine Hall A, Circus Rd W, Nine Elms"
# street_address2 = "Suite 1100"
# city = "London"
# state_province = "London"
# zip_postal_code = "SW11 8AL"
# country = "United Kingdom"
# }
156 changes: 30 additions & 126 deletions workload/terraform/jamfpro/computer_extension_attributes.tf
Original file line number Diff line number Diff line change
@@ -1,127 +1,31 @@
// pop up

// old v0.2.0
# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_001" {
# name = "tf-state-migration-test-001"
# enabled = true
# description = "An attribute collected from a pop-up menu."
# input_type = "Pop-up Menu"
# input_popup = ["Option 1", "Option 2", "Option 3"]
# inventory_display = "User and Location"
# }

// new v0.3.0

# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_001" {
# name = "tf-state-migration-test-001"
# enabled = true
# description = "An attribute collected from a pop-up menu."
# input_type = "POPUP"
# popup_menu_choices = ["Option 1", "Option 2", "Option 3"]
# inventory_display_type = "USER_AND_LOCATION"
# data_type = "STRING"
# }

# //-------------------------------------------------------------------//
// text

// old v0.2.0
# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_002" {
# name = "tf-state-migration-test-002"
# enabled = true
# description = "An attribute collected from a text field."
# input_type = "Text Field"
# inventory_display = "Hardware"
# }

// new v0.3.0

# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_002" {
# name = "tf-state-migration-test-002"
# enabled = true
# description = "An attribute collected from a text field."
# input_type = "TEXT"
# inventory_display_type = "HARDWARE"
# data_type = "STRING"
# }


# //-------------------------------------------------------------------//
// script

// old v0.2.0
# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_003" {
# name = "tf-state-migration-test-003"
# enabled = true
# description = "An attribute collected via a script."
# input_type = "script"
# input_script = <<-SHELL
# #!/bin/sh
# /bin/echo "<result>sample</result>"
# SHELL

# inventory_display = "General"
# }

# New v0.3.0

# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_003" {
# name = "tf-state-migration-test-003"
# enabled = true
# inventory_display_type = "EXTENSION_ATTRIBUTES"
# data_type = "STRING"
# input_type = "SCRIPT"
# script_contents = <<-SHELL
# #!/bin/sh
# /bin/echo "<result>sample</result>"
# SHELL
# }







# Pop-up Menu Example
# resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_popup_menu_1" {
# name = "tf-demo-popup-menu-example"
# enabled = true
# description = "An attribute collected from a pop-up menu."
# input_type = "POPUP"
# popup_menu_choices = ["Option 1", "Option 2", "Option 3"]
# inventory_display_type = "USER_AND_LOCATION"
# data_type = "STRING"
# }

# # Text Field Example
# resource "jamfpro_computer_extension_attribute" "computer_extension_attribute_text_field_1" {
# name = "tf-demo-text-field-example"
# enabled = true
# description = "An attribute collected from a text field."
# input_type = "TEXT"
# inventory_display_type = "HARDWARE"
# data_type = "STRING"
# }

# # Script Example
# resource "jamfpro_computer_extension_attribute" "computer_extension_attribute_script_1" {
# name = "tf-demo-hello-world"
# enabled = true
# description = "An attribute collected via a script."
# input_type = "SCRIPT"
# script_contents = "#!/bin/bash\necho 'Hello, World!!!!! :)'"
# inventory_display_type = "GENERAL"
# data_type = "STRING"
# }

# # Script Example
# resource "jamfpro_computer_extension_attribute" "computer_extension_attribute_script_2" {
# name = "tf-demo-logged-in-user"
# enabled = true
# description = "An attribute collected via a script."
# input_type = "SCRIPT"
# script_contents = file("support_files/computer_extension_attributes/logged_in_user.sh")
# inventory_display_type = "GENERAL"
# data_type = "STRING"
# }
resource "jamfpro_computer_extension_attribute" "jamfpro_computer_extension_attribute_popup_menu_1" {
name = "tf-demo-cexa-popup-menu-example"
enabled = true
description = "An attribute collected from a pop-up menu."
input_type = "POPUP"
popup_menu_choices = ["Option 1", "Option 2", "Option 3"]
inventory_display_type = "USER_AND_LOCATION"
data_type = "STRING"
}

# Text Field Example
resource "jamfpro_computer_extension_attribute" "computer_extension_attribute_text_field_1" {
name = "tf-demo-cexa-text-field-example"
enabled = true
description = "An attribute collected from a text field."
input_type = "TEXT"
inventory_display_type = "HARDWARE"
data_type = "STRING"
}

# Script Example
resource "jamfpro_computer_extension_attribute" "computer_extension_attribute_script_1" {
name = "tf-demo-cexa-hello-world"
enabled = true
description = "An attribute collected via a script."
input_type = "SCRIPT"
script_contents = "#!/bin/bash\necho 'Hello, World!!!!! :)'"
inventory_display_type = "GENERAL"
data_type = "STRING"
}
Loading