|
1 | | -# Template |
| 1 | +# jamftf-python-terraform-importer |
2 | 2 |
|
3 | | -This repository serves as a **Default Template Repository** according official [GitHub Contributing Guidelines][ProjectSetup] for healthy contributions. It brings you clean default Templates for several areas: |
| 3 | +A Python-based utility to automate the import of existing Jamf Pro resources into Terraform state files. |
4 | 4 |
|
5 | | -- [Azure DevOps Pull Requests](.azuredevops/PULL_REQUEST_TEMPLATE.md) ([`.azuredevops\PULL_REQUEST_TEMPLATE.md`](`.azuredevops\PULL_REQUEST_TEMPLATE.md`)) |
6 | | -- [Azure Pipelines](.pipelines/pipeline.yml) ([`.pipelines/pipeline.yml`](`.pipelines/pipeline.yml`)) |
7 | | -- [GitHub Workflows](.github/workflows/) |
8 | | - - [Super Linter](.github/workflows/linter.yml) ([`.github/workflows/linter.yml`](`.github/workflows/linter.yml`)) |
9 | | - - [Sample Workflows](.github/workflows/workflow.yml) ([`.github/workflows/workflow.yml`](`.github/workflows/workflow.yml`)) |
10 | | -- [GitHub Pull Requests](.github/PULL_REQUEST_TEMPLATE.md) ([`.github/PULL_REQUEST_TEMPLATE.md`](`.github/PULL_REQUEST_TEMPLATE.md`)) |
11 | | -- [GitHub Issues](.github/ISSUE_TEMPLATE/) |
12 | | - - [Feature Requests](.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md) ([`.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md`](`.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md`)) |
13 | | - - [Bug Reports](.github/ISSUE_TEMPLATE/BUG_REPORT.md) ([`.github/ISSUE_TEMPLATE/BUG_REPORT.md`](`.github/ISSUE_TEMPLATE/BUG_REPORT.md`)) |
14 | | -- [Codeowners](.github/CODEOWNERS) ([`.github/CODEOWNERS`](`.github/CODEOWNERS`)) _adjust usernames once cloned_ |
15 | | -- [Wiki and Documentation](docs/) ([`docs/`](`docs/`)) |
16 | | -- [gitignore](.gitignore) ([`.gitignore`](.gitignore)) |
17 | | -- [gitattributes](.gitattributes) ([`.gitattributes`](.gitattributes)) |
18 | | -- [Changelog](CHANGELOG.md) ([`CHANGELOG.md`](`CHANGELOG.md`)) |
19 | | -- [Code of Conduct](CODE_OF_CONDUCT.md) ([`CODE_OF_CONDUCT.md`](`CODE_OF_CONDUCT.md`)) |
20 | | -- [Contribution](CONTRIBUTING.md) ([`CONTRIBUTING.md`](`CONTRIBUTING.md`)) |
21 | | -- [License](LICENSE) ([`LICENSE`](`LICENSE`)) _adjust projectname once cloned_ |
22 | | -- [Readme](README.md) ([`README.md`](`README.md`)) |
23 | | -- [Security](SECURITY.md) ([`SECURITY.md`](`SECURITY.md`)) |
| 5 | +## Overview |
24 | 6 |
|
| 7 | +Managing Jamf Pro resources with Terraform enhances reproducibility, version control, and automation. However, importing existing Jamf Pro resources into Terraform can be tedious and error-prone. This tool simplifies the process by: |
25 | 8 |
|
26 | | -## Status |
| 9 | +- Connecting to your Jamf Pro tenant via the Classic API. |
| 10 | +- Fetching specified resources (e.g., scripts, policies, configuration profiles). |
| 11 | +- Generating Terraform import blocks for each resource. |
27 | 12 |
|
28 | | -[](<https://github.com/segraef/Template/actions/workflows/linter.yml>) |
| 13 | +This facilitates a smoother transition to Infrastructure as Code (IaC) practices with Jamf Pro. |
29 | 14 |
|
30 | | -[](<https://github.com/segraef/Template/actions/workflows/workflow.yml>) |
| 15 | +## Features |
31 | 16 |
|
32 | | -## Creating a repository from a template |
| 17 | +- Supports multiple Jamf Pro resource types. |
| 18 | +- Generates Terraform import blocks compatible with Terraform v1.5 and above. |
| 19 | +- Modular design for easy extension to additional resource types. |
| 20 | +- Command-line interface for straightforward operation. |
33 | 21 |
|
34 | | -You can [generate](https://github.com/segraef/Template/generate) a new repository with the same directory structure and files as an existing repository. More details can be found [here][CreateFromTemplate]. |
| 22 | +## Prerequisites |
35 | 23 |
|
36 | | -## Reporting Issues and Feedback |
| 24 | +- Python 3.7 or higher |
| 25 | +- Access to a Jamf Pro instance with appropriate API credentials |
| 26 | +- Terraform v1.5 or higher |
37 | 27 |
|
38 | | -### Issues and Bugs |
| 28 | +## Installation |
39 | 29 |
|
40 | | -If you find any bugs, please file an issue in the [GitHub Issues][GitHubIssues] page. Please fill out the provided template with the appropriate information. |
| 30 | +1. Clone the repository: |
41 | 31 |
|
42 | | -If you are taking the time to mention a problem, even a seemingly minor one, it is greatly appreciated, and a totally valid contribution to this project. **Thank you!** |
| 32 | + ```bash |
| 33 | + git clone https://github.com/deploymenttheory/jamftf-python-terraform-importer.git |
| 34 | + cd jamftf-python-terraform-importer |
| 35 | + ``` |
43 | 36 |
|
44 | | -## Feedback |
| 37 | +2. Install the required Python packages: |
45 | 38 |
|
46 | | -If there is a feature you would like to see in here, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to provide direct feedback. |
| 39 | + ```bash |
| 40 | + pip install -r requirements.txt |
| 41 | + ``` |
47 | 42 |
|
48 | | -## Contribution |
| 43 | +## Usage |
49 | 44 |
|
50 | | -If you would like to become an active contributor to this repository or project, please follow the instructions provided in [`CONTRIBUTING.md`][Contributing]. |
| 45 | +1. Configure your Jamf Pro API credentials and desired resources using environment variables or a JSON config file like `import_config.json`: |
51 | 46 |
|
52 | | -## Learn More |
| 47 | + ```json |
| 48 | + { |
| 49 | + "jamfpro_macos_configuration_profile_plist": true |
| 50 | + } |
| 51 | + ``` |
53 | 52 |
|
54 | | -* [GitHub Documentation][GitHubDocs] |
55 | | -* [Azure DevOps Documentation][AzureDevOpsDocs] |
56 | | -* [Microsoft Azure Documentation][MicrosoftAzureDocs] |
| 53 | +2. Run the importer script: |
57 | 54 |
|
58 | | -<!-- References --> |
| 55 | + ```bash |
| 56 | + python main.py |
| 57 | + ``` |
59 | 58 |
|
60 | | -<!-- Local --> |
61 | | -[ProjectSetup]: <https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions> |
62 | | -[CreateFromTemplate]: <https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/creating-a-repository-from-a-template> |
63 | | -[GitHubDocs]: <https://docs.github.com/> |
64 | | -[AzureDevOpsDocs]: <https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops> |
65 | | -[GitHubIssues]: <https://github.com/segraef/Template/issues> |
66 | | -[Contributing]: CONTRIBUTING.md |
| 59 | + This will generate Terraform import blocks for the selected resource types. |
67 | 60 |
|
68 | | -<!-- External --> |
69 | | -[Az]: <https://img.shields.io/powershellgallery/v/Az.svg?style=flat-square&label=Az> |
70 | | -[AzGallery]: <https://www.powershellgallery.com/packages/Az/> |
71 | | -[PowerShellCore]: <https://github.com/PowerShell/PowerShell/releases/latest> |
| 61 | +3. Use the generated import blocks to import resources into Terraform state: |
72 | 62 |
|
73 | | -<!-- Docs --> |
74 | | -[MicrosoftAzureDocs]: <https://docs.microsoft.com/en-us/azure/> |
75 | | -[PowerShellDocs]: <https://docs.microsoft.com/en-us/powershell/> |
| 63 | + ```bash |
| 64 | + terraform import <resource_type>.<resource_name> <resource_id> |
| 65 | + ``` |
| 66 | + |
| 67 | +## Supported Resources |
| 68 | + |
| 69 | +- Scripts |
| 70 | +- Policies |
| 71 | +- Configuration Profiles |
| 72 | +- Categories |
| 73 | +- Computer Groups (Static and Smart) |
| 74 | +- Advanced Computer Searches |
| 75 | +- Computer Extension Attributes |
| 76 | + |
| 77 | +Support for additional resource types can be added by extending the `Resource` class and implementing the `_get()` method. |
| 78 | + |
| 79 | +## Contributing |
| 80 | + |
| 81 | +Contributions are welcome! Please submit a pull request or open an issue to propose changes or enhancements. |
| 82 | + |
| 83 | +## License |
| 84 | + |
| 85 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +For more information and updates, visit the [GitHub repository](https://github.com/deploymenttheory/jamftf-python-terraform-importer). |
0 commit comments