ForkCoreWeaveCoreWeavepublished Jul 16, 2024seen 6d

coreweave/terraformer

forked from GoogleCloudPlatform/terraformer

Open original ↗

Captured source

source ↗
published Jul 16, 2024seen 6dcaptured 15hhttp 200method plain

coreweave/terraformer

Description: CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code

License: Apache-2.0

Stars: 0

Forks: 0

Open issues: 0

Created: 2024-07-16T17:18:30Z

Pushed: 2024-07-16T17:21:42Z

Default branch: master

Fork: yes

Parent repository: GoogleCloudPlatform/terraformer

Archived: yes

README:

Terraformer

![tests](https://github.com/GoogleCloudPlatform/terraformer/actions/workflows/test.yml) ![linter](https://github.com/GoogleCloudPlatform/terraformer/actions/workflows/linter.yml) ![Go Report Card](https://goreportcard.com/report/github.com/GoogleCloudPlatform/terraformer)

A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform).

  • Disclaimer: This is not an official Google product
  • Created by: Waze SRE

![Waze SRE logo](assets/waze-sre-logo.png)

Table of Contents

  • [Demo GCP](#demo-gcp)
  • [Capabilities](#capabilities)
  • [Installation](#installation)
  • [Supported Providers](/docs)
  • Major Cloud
  • [Google Cloud](/docs/gcp.md)
  • [AWS](/docs/aws.md)
  • [Azure](/docs/azure.md)
  • [AliCloud](/docs/alicloud.md)
  • [IBM Cloud](/docs/ibmcloud.md)
  • Cloud
  • [DigitalOcean](/docs/digitalocean.md)
  • [Equinix Metal](/docs/equinixmetal.md)
  • [Fastly](/docs/fastly.md)
  • [Heroku](/docs/heroku.md)
  • [LaunchDarkly](/docs/launchdarkly.md)
  • [Linode](/docs/linode.md)
  • [NS1](/docs/ns1.md)
  • [OpenStack](/docs/openstack.md)
  • [TencentCloud](/docs/tencentcloud.md)
  • [Vultr](/docs/vultr.md)
  • [Yandex Cloud](/docs/yandex.md)
  • [Ionos Cloud](/docs/ionoscloud.md)
  • Infrastructure Software
  • [Kubernetes](/docs/kubernetes.md)
  • [OctopusDeploy](/docs/octopus.md)
  • [RabbitMQ](/docs/rabbitmq.md)
  • Network
  • [Cloudflare](/docs/cloudflare.md)
  • [Myrasec](/docs/myrasec.md)
  • [PAN-OS](/docs/panos.md)
  • VCS
  • [Azure DevOps](/docs/azuredevops.md)
  • [GitHub](/docs/github.md)
  • [Gitlab](/docs/gitlab.md)
  • Monitoring & System Management
  • [Datadog](/docs/datadog.md)
  • [New Relic](/docs/relic.md)
  • [Mackerel](/docs/mackerel.md)
  • [PagerDuty](/docs/pagerduty.md)
  • [Opsgenie](/docs/opsgenie.md)
  • [Honeycomb.io](/docs/honeycombio.md)
  • [Opal](/docs/opal.md)
  • Community
  • [Keycloak](/docs/keycloak.md)
  • [Logz.io](/docs/logz.md)
  • [Commercetools](/docs/commercetools.md)
  • [Mikrotik](/docs/mikrotik.md)
  • [Xen Orchestra](/docs/xen.md)
  • [GmailFilter](/docs/gmailfilter.md)
  • [Grafana](/docs/grafana.md)
  • [Vault](/docs/vault.md)
  • Identity
  • [Okta](/docs/okta.md)
  • [Auth0](/docs/auth0.md)
  • [AzureAD](/docs/azuread.md)
  • [Contributing](#contributing)
  • [Developing](#developing)
  • [Infrastructure](#infrastructure)
  • [Stargazers over time](#stargazers-over-time)

Demo GCP

![asciicast](https://asciinema.org/a/243961)

Capabilities

1. Generate tf/json + tfstate files from existing infrastructure for all supported objects by resource. 2. Remote state can be uploaded to a GCS bucket. 3. Connect between resources with terraform_remote_state (local and bucket). 4. Save tf/json files using a custom folder tree pattern. 5. Import by resource name and type. 6. Support terraform 0.13 (for terraform 0.11 use v0.7.9).

Terraformer uses Terraform providers and is designed to easily support newly added resources. To upgrade resources with new fields, all you need to do is upgrade the relevant Terraform providers.

Import current state to Terraform configuration from a provider

Usage:
import [provider] [flags]
import [provider] [command]

Available Commands:
list List supported resources for a provider

Flags:
-b, --bucket string gs://terraform-state
-c, --connect (default true)
-С, --compact (default false)
-x, --excludes strings firewalls,networks
-f, --filter strings compute_firewall=id1:id2:id4
-h, --help help for google
-O, --output string output format hcl or json (default "hcl")
-o, --path-output string (default "generated")
-p, --path-pattern string {output}/{provider}/ (default "{output}/{provider}/{service}/")
--projects strings
-z, --regions strings europe-west1, (default [global])
-r, --resources strings firewall,networks or * for all services
-s, --state string local or bucket (default "local")
-v, --verbose verbose mode
-n, --retry-number number of retries to perform if refresh fails
-m, --retry-sleep-ms time in ms to sleep between retries

Use " import [provider] [command] --help" for more information about a command.

Permissions

The tool requires read-only permissions to list service resources.

Resources

You can use --resources parameter to tell resources from what service you want to import.

To import resources from all services, use --resources="*" . If you want to exclude certain services, you can combine the parameter with --excludes to exclude resources from services you don't want to import e.g. --resources="*" --excludes="iam".

Filtering

Filters are a way to choose which resources terraformer imports. It's possible to filter resources by its identifiers or attributes. Multiple filtering values are separated by :. If an identifier contains this symbol, value should be wrapped in ' e.g. --filter=resource=id1:'project:dataset_id'. Identifier based filters will be executed before Terraformer will try to refresh remote state.

Use Type when you need to filter only one of several types of resources. Multiple filters can be combined when importing different resource types. An example would be importing all AWS security groups from a specific AWS VPC:

terraformer import aws -r sg,vpc --filter Type=sg;Name=vpc_id;Value=VPC_ID --filter Type=vpc;Name=id;Value=VPC_ID

Notice how the Name is different for sg than it is for vpc.

##### Migration state version For terraform >= 0.13, you can use replace-provider to migrate state from previous versions.

Example usage:

terraform state replace-provider -auto-approve "registry.terraform.io/-/aws" "hashicorp/aws"

##### Resource ID

Filtering is based on Terraform resource ID patterns. To find valid ID patterns for your resource, check the import part of the [Terraform documentation][terraform-providers].

[terraform-providers]: https://www.terraform.io/docs/providers/…

Excerpt shown — open the source for the full document.

Notability

notability 1.0/10

Routine fork, low traction.