├── .github └── workflows │ └── release.yml ├── .gitignore ├── .go-version ├── .goreleaser.yml ├── GNUmakefile ├── README.md ├── import.sh ├── run.sh ├── temp.json └── tfrefactor ├── README.md ├── command ├── meta.go └── resource.go ├── go.mod ├── go.sum ├── main.go └── tfrefactor ├── enum.go ├── file.go ├── file_test.go ├── migrate.go ├── option.go ├── s3_bucket.go ├── testdata ├── acceleration_status │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── acl │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── cors_rule │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── dynamic │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── full │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── grant │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── lifecycle_rule │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── logging │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── object_lock_configuration │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── policy │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── replication_configuration │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── request_payer │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── server_side_encryption_configuration │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv ├── versioning │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv └── website │ ├── main.tf │ ├── main_migrated.tf │ └── main_new_resources.csv └── types.go /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | permissions: 3 | contents: write 4 | 5 | on: 6 | push: 7 | tags: 8 | - "v[0-9]+.*" 9 | 10 | jobs: 11 | go-version: 12 | runs-on: ubuntu-latest 13 | outputs: 14 | version: ${{ steps.go-version.outputs.version }} 15 | steps: 16 | - uses: actions/checkout@v2 17 | - id: go-version 18 | run: echo "::set-output name=version::$(cat ./.go-version)" 19 | Release: 20 | runs-on: ubuntu-latest 21 | timeout-minutes: 5 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v2 25 | with: 26 | fetch-depth: 0 27 | - name: Setup Go 28 | uses: actions/setup-go@v2 29 | with: 30 | go-version: ${{ inputs.setup-go-version }} 31 | - name: Run GoReleaser 32 | uses: goreleaser/goreleaser-action@v2 33 | with: 34 | version: latest 35 | args: release --rm-dist 36 | env: 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform.lock.hcl 2 | terraform.tfstate 3 | .terraform -------------------------------------------------------------------------------- /.go-version: -------------------------------------------------------------------------------- 1 | 1.17.6 2 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Build customization 2 | archives: 3 | - format: zip 4 | name_template: 'tfrefactor_{{ .Version }}_{{ .Os }}_{{ .Arch }}' 5 | builds: 6 | - binary: tfrefactor 7 | dir: tfrefactor 8 | goarch: 9 | - '386' 10 | - amd64 11 | - arm 12 | - arm64 13 | goos: 14 | - darwin 15 | - freebsd 16 | - linux 17 | - windows 18 | ignore: 19 | - goarch: '386' 20 | goos: darwin 21 | env: 22 | - CGO_ENABLED=0 23 | checksum: 24 | name_template: 'tfrefactor_{{ .Version }}_checksums.txt' 25 | release: 26 | prerelease: auto 27 | changelog: 28 | skip: true 29 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | NAME := tfrefactor 2 | SRC_DIR := ./tfrefactor 3 | 4 | .DEFAULT_GOAL := build 5 | 6 | .PHONY: deps 7 | deps: 8 | cd $(SRC_DIR) && go mod download 9 | 10 | .PHONY: build 11 | build: deps 12 | cd $(SRC_DIR) && go build -o ~/go/bin/$(NAME) 13 | 14 | .PHONY: install 15 | install: deps 16 | cd $(SRC_DIR) && go install 17 | 18 | .PHONY: lint 19 | lint: 20 | golangci-lint run ./... 21 | 22 | .PHONY: test 23 | test: build 24 | go test ./$(SRC_DIR)/... 25 | 26 | .PHONY: check 27 | check: lint test -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ohmyhcl 2 | A playground for experimenting with hclwrite and tfupdate, inspired by hcledit. In the spirit of [`ohmyzsh`](https://github.com/ohmyzsh/ohmyzsh), the vision of this 3 | repository is to bundle different helpful tools for managing your HCL configurations, namely Terraform, and perhaps one day become an interactive framework. 4 | 5 | ## Description 6 | 7 | This repository currently houses the experimental tools [`tfrefactor`](./tfrefactor) and upcoming `tfimportgen` to assist migrating terraform configurations from v3 Terraform AWS Provider to v4 where S3 bucket refactoring is necessary. 8 | -------------------------------------------------------------------------------- /import.sh: -------------------------------------------------------------------------------- 1 | #/usr/local/bin/bash 2 | terraform import aws_s3_bucket_acl.b_acl stunning-scorpion 3 | terraform import aws_s3_bucket_acl.log_bucket_acl my-example-log-bucket-44444 4 | terraform import aws_s3_bucket_accelerate_configuration.example_acceleration_configuration tf-acc-test-abc12345 5 | terraform import aws_s3_bucket_policy.example_policy tf-acc-test-abc12345 6 | terraform import aws_s3_bucket_request_payment_configuration.example_request_payment_configuration tf-acc-test-abc12345 7 | terraform import aws_s3_bucket_cors_configuration.example_cors_configuration tf-acc-test-abc12345 8 | terraform import aws_s3_bucket_acl.example_acl tf-acc-test-abc12345 9 | terraform import aws_s3_bucket_logging.example_logging tf-acc-test-abc12345 10 | terraform import aws_s3_bucket_versioning.example_versioning tf-acc-test-abc12345 11 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #/usr/local/bin/bash 2 | 3 | # TEST 4 | 5 | OUTFILE=import.sh 6 | ERRORFILE=errors.log 7 | 8 | echo "#/usr/local/bin/bash" >> $OUTFILE 9 | 10 | # 1. Generate json of tfstate if not supplied 11 | 12 | TFSTATE_JSON=$1 13 | if [ -z "$TFSTATE_JSON" ]; then 14 | terraform show -json > temp.json 15 | TFSTATE_JSON=temp.json 16 | fi 17 | 18 | # 2. Run Migration 19 | tfrefactor resource aws_s3_bucket ./terraform -provider-version "~> 4.0" 20 | 21 | #. 3. For each new resource, find the corresponding bucket ID in tfstate to generate import statements 22 | while IFS=, read -r field1 field2 23 | do 24 | ID=$(jq -r '.values[].resources[] | select(.address == "'"$field2"'") | .values.id' $TFSTATE_JSON) 25 | if [ -z "$ID" ]; then 26 | echo "[ERROR] unable to determine import ID for $field1" >> $ERRORFILE 27 | fi 28 | echo "terraform import $field1 $ID" >> $OUTFILE 29 | done < ./output/resources.csv 30 | 31 | -------------------------------------------------------------------------------- /temp.json: -------------------------------------------------------------------------------- 1 | {"format_version":"1.0","terraform_version":"1.1.5","values":{"root_module":{"resources":[{"address":"aws_s3_bucket.b","mode":"managed","type":"aws_s3_bucket","name":"b","provider_name":"registry.terraform.io/hashicorp/aws","schema_version":0,"values":{"acceleration_status":"","acl":"public-read","arn":"arn:aws:s3:::stunning-scorpion","bucket":"stunning-scorpion","bucket_domain_name":"stunning-scorpion.s3.amazonaws.com","bucket_prefix":null,"bucket_regional_domain_name":"stunning-scorpion.s3.us-west-2.amazonaws.com","cors_rule":[],"force_destroy":false,"grant":[],"hosted_zone_id":"Z3BJ6K6RIION7M","id":"stunning-scorpion","lifecycle_rule":[],"logging":[],"object_lock_configuration":[],"policy":null,"region":"us-west-2","replication_configuration":[],"request_payer":"BucketOwner","server_side_encryption_configuration":[],"tags":null,"tags_all":{},"versioning":[{"enabled":false,"mfa_delete":false}],"website":[],"website_domain":null,"website_endpoint":null},"sensitive_values":{"cors_rule":[],"grant":[],"lifecycle_rule":[],"logging":[],"object_lock_configuration":[],"replication_configuration":[],"server_side_encryption_configuration":[],"tags_all":{},"versioning":[{}],"website":[]},"depends_on":["random_pet.example"]},{"address":"aws_s3_bucket.example","mode":"managed","type":"aws_s3_bucket","name":"example","provider_name":"registry.terraform.io/hashicorp/aws","schema_version":0,"values":{"acceleration_status":"Enabled","acl":"private","arn":"arn:aws:s3:::tf-acc-test-abc12345","bucket":"tf-acc-test-abc12345","bucket_domain_name":"tf-acc-test-abc12345.s3.amazonaws.com","bucket_prefix":null,"bucket_regional_domain_name":"tf-acc-test-abc12345.s3.us-west-2.amazonaws.com","cors_rule":[{"allowed_headers":["*"],"allowed_methods":["PUT","POST"],"allowed_origins":["https://www.example.com"],"expose_headers":["x-amz-server-side-encryption","ETag"],"max_age_seconds":3000},{"allowed_headers":["*"],"allowed_methods":["GET"],"allowed_origins":[""],"expose_headers":["x-amz-server-side-encryption","ETag"],"max_age_seconds":3000}],"force_destroy":false,"grant":[{"id":"","permissions":["READ_ACP"],"type":"Group","uri":"http://acs.amazonaws.com/groups/s3/LogDelivery"},{"id":"f9e125aeb3d6f461f66e83c6a9f489cb4f31a0be7e670a729424ee32326ceeb1","permissions":["FULL_CONTROL","WRITE"],"type":"CanonicalUser","uri":""}],"hosted_zone_id":"Z3BJ6K6RIION7M","id":"tf-acc-test-abc12345","lifecycle_rule":[],"logging":[{"target_bucket":"my-example-log-bucket-44444","target_prefix":"log/"}],"object_lock_configuration":[],"policy":"{\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Resource\":\"arn:aws:s3:::tf-acc-test-abc12345/*\",\"Sid\":\"AllowPublicRead\"}],\"Version\":\"2008-10-17\"}","region":"us-west-2","replication_configuration":[],"request_payer":"Requester","server_side_encryption_configuration":[],"tags":null,"tags_all":{},"versioning":[{"enabled":true,"mfa_delete":false}],"website":[],"website_domain":null,"website_endpoint":null},"sensitive_values":{"cors_rule":[{"allowed_headers":[false],"allowed_methods":[false,false],"allowed_origins":[false],"expose_headers":[false,false]},{"allowed_headers":[false],"allowed_methods":[false],"allowed_origins":[false],"expose_headers":[false,false]}],"grant":[{"permissions":[false]},{"permissions":[false,false]}],"lifecycle_rule":[],"logging":[{}],"object_lock_configuration":[],"replication_configuration":[],"server_side_encryption_configuration":[],"tags_all":{},"versioning":[{}],"website":[]},"depends_on":["aws_s3_bucket.log_bucket","data.aws_canonical_user_id.current","data.aws_partition.current"]},{"address":"aws_s3_bucket.log_bucket","mode":"managed","type":"aws_s3_bucket","name":"log_bucket","provider_name":"registry.terraform.io/hashicorp/aws","schema_version":0,"values":{"acceleration_status":"","acl":"private","arn":"arn:aws:s3:::my-example-log-bucket-44444","bucket":"my-example-log-bucket-44444","bucket_domain_name":"my-example-log-bucket-44444.s3.amazonaws.com","bucket_prefix":null,"bucket_regional_domain_name":"my-example-log-bucket-44444.s3.us-west-2.amazonaws.com","cors_rule":[],"force_destroy":false,"grant":[],"hosted_zone_id":"Z3BJ6K6RIION7M","id":"my-example-log-bucket-44444","lifecycle_rule":[],"logging":[],"object_lock_configuration":[],"policy":null,"region":"us-west-2","replication_configuration":[],"request_payer":"BucketOwner","server_side_encryption_configuration":[],"tags":null,"tags_all":{},"versioning":[{"enabled":false,"mfa_delete":false}],"website":[],"website_domain":null,"website_endpoint":null},"sensitive_values":{"cors_rule":[],"grant":[],"lifecycle_rule":[],"logging":[],"object_lock_configuration":[],"replication_configuration":[],"server_side_encryption_configuration":[],"tags_all":{},"versioning":[{}],"website":[]}},{"address":"data.aws_canonical_user_id.current","mode":"data","type":"aws_canonical_user_id","name":"current","provider_name":"registry.terraform.io/hashicorp/aws","schema_version":0,"values":{"display_name":"aws-hc1-tf_aws_provider3_test","id":"f9e125aeb3d6f461f66e83c6a9f489cb4f31a0be7e670a729424ee32326ceeb1"},"sensitive_values":{}},{"address":"data.aws_partition.current","mode":"data","type":"aws_partition","name":"current","provider_name":"registry.terraform.io/hashicorp/aws","schema_version":0,"values":{"dns_suffix":"amazonaws.com","id":"aws","partition":"aws","reverse_dns_prefix":"com.amazonaws"},"sensitive_values":{}},{"address":"random_pet.example","mode":"managed","type":"random_pet","name":"example","provider_name":"registry.terraform.io/hashicorp/random","schema_version":0,"values":{"id":"stunning-scorpion","keepers":null,"length":2,"prefix":null,"separator":"-"},"sensitive_values":{}}]}}} 2 | -------------------------------------------------------------------------------- /tfrefactor/README.md: -------------------------------------------------------------------------------- 1 | [![stability-experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](https://github.com/emersion/stability-badges#experimental) 2 | 3 | # tfrefactor 4 | 5 | ## Features 6 | 7 | - Migrate `aws_s3_bucket` resource arguments to independent resources available since `v4.0.0` of the Terraform AWS Provider. 8 | - Update version constraints of the Terraform AWS Provider defined in configurations. 9 | - Get a table (in `.csv` format) of each new resource with its parent `aws_s3_bucket` to enable resource import. 10 | 11 | ## Limitations 12 | 13 | - Migrating `dynamic` arguments. This is done as a _best-effort_ attempt. Current _best_effort_ support available is for the `cors_rule`, `logging`, and `website` arguments. 14 | - Migrating `aws_s3_bucket` `routing_rules` (String) to `aws_s3_bucket_website_configuration` `routing_rule` configuration blocks 15 | if the given literal value is not a JSON or YAML representation of RoutingRules. 16 | 17 | For example, given the following configuration: 18 | ```shell 19 | $ cat main.tf 20 | 21 | resource "aws_s3_bucket" "example" { 22 | # ... other configuration ... 23 | dynamic "website" { 24 | for_each = length(keys(var.website)) == 0 ? [] : [var.website] 25 | 26 | content { 27 | index_document = lookup(website.value, "index_document", null) 28 | error_document = lookup(website.value, "error_document", null) 29 | redirect_all_requests_to = lookup(website.value, "redirect_all_requests_to", null) 30 | routing_rules = lookup(website.value, "routing_rules", null) 31 | } 32 | } 33 | } 34 | ``` 35 | 36 | The `aws_s3_bucket_website_configuration` resource in `main_migrated.tf` will look like: 37 | ```terraform 38 | resource "aws_s3_bucket_website_configuration" "this_website_configuration" { 39 | for_each = length(keys(var.website)) == 0 ? [] : [var.website] 40 | 41 | bucket = aws_s3_bucket.this[each.key].id 42 | # TODO: Replace with your 'routing_rule' configuration 43 | index_document { 44 | suffix = lookup(each.value, "index_document", null) 45 | } 46 | error_document { 47 | key = lookup(each.value, "error_document", null) 48 | } 49 | redirect_all_requests_to { 50 | host_name = lookup(each.value, "redirect_all_requests_to", null) 51 | } 52 | } 53 | ``` 54 | 55 | ### Download 56 | 57 | Download the latest compiled binaries and put it anywhere in your executable path. 58 | 59 | https://github.com/anGie44/ohmyhcl/releases 60 | 61 | ### Source 62 | 63 | If you have Go 1.17+ development environment: 64 | 65 | ``` 66 | $ git clone https://github.com/anGie44/ohmyhcl 67 | $ cd ohmyhcl/ 68 | $ make install 69 | ``` 70 | 71 | ## Usage 72 | ```shell 73 | tfrefactor --help 74 | Usage: tfrefactor [--version] [--help] [] 75 | 76 | Available commands are: 77 | resource Migrate resource arguments to individual resources 78 | ``` 79 | 80 | ### resource 81 | 82 | ```shell 83 | $ tfrefactor resource --help 84 | Usage: tfrefactor resource [options] 85 | Arguments 86 | RESOURCE_TYPE The provider resource type (e.g. aws_s3_bucket) 87 | PATH A path of file or directory to update 88 | Options: 89 | --ignore-arguments The arguments in the to ignore 90 | Set the flag with values separated by commas (e.g. --ignore-arguments="acl,grant") or set the flag multiple times. 91 | --ignore-names The resource names of to ignore 92 | Set the flag with values separated by commas (e.g. --ignore-names="example,log_bucket") or set the flag multiple times. 93 | -i --ignore-paths Regular expressions for path to ignore 94 | Set the flag with values separated by commas or set the flag multiple times. 95 | -c --csv Generate a CSV file of new resources and their parent resource (default: false) 96 | -p --provider-version The provider version constraint (default: v4.0.0) 97 | -r --recursive Check a directory recursively (default: false) 98 | ``` 99 | 100 | ```shell 101 | $ cat main.tf 102 | provider "aws" { 103 | version = "2.39.0" 104 | } 105 | 106 | resource "aws_s3_bucket" "example" { 107 | bucket = var.bucket 108 | acl = "private" 109 | 110 | server_side_encryption_configuration { 111 | rule { 112 | apply_server_side_encryption_by_default { 113 | kms_master_key_id = aws_kms_key.arbitrary.arn 114 | sse_algorithm = "aws:kms" 115 | } 116 | } 117 | } 118 | } 119 | 120 | $ tfrefactor resource aws_s3_bucket main.tf 121 | 122 | $ cat main_migrated.tf 123 | provider "aws" { 124 | version = "4.0.0" 125 | } 126 | 127 | resource "aws_s3_bucket" "example" { 128 | bucket = var.bucket 129 | } 130 | 131 | resource "aws_s3_bucket_acl" "example_acl" { 132 | bucket = aws_s3_bucket.example.id 133 | acl = "private" 134 | } 135 | 136 | resource "aws_s3_bucket_server_side_encryption_configuration" "example_server_side_encryption_configuration" { 137 | bucket = aws_s3_bucket.example.id 138 | rule { 139 | apply_server_side_encryption_by_default { 140 | kms_master_key_id = aws_kms_key.arbitrary.arn 141 | sse_algorithm = "aws:kms" 142 | } 143 | } 144 | } 145 | ``` 146 | 147 | ## Output Logging 148 | 149 | Set the environment variable `TFREFACTOR_LOG` to the log-level of choice. Valid values include: `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`. 150 | 151 | ## Credit 152 | 153 | Credit is due to [@minamijoyo](https://github.com/minamijoyo) (and community contributors) and their [`tfupdate`](https://github.com/minamijoyo/tfupdate) and [`hcledit`](https://github.com/minamijoyo/hcledit) projects, 154 | as `tfrefactor` is in essence an extension to that functionality and much of the foundation and CLI implementation of this tool takes from their existing code and patterns. 155 | The goal of this project was to develop a tool, quickly and with a familiar UX, and the existing projects made it come to fruition sooner than expected. 156 | -------------------------------------------------------------------------------- /tfrefactor/command/meta.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "github.com/mitchellh/cli" 5 | "github.com/spf13/afero" 6 | ) 7 | 8 | type Meta struct { 9 | // UI is a user interface representing input and output. 10 | UI cli.Ui 11 | 12 | // Fs is an afero filesystem. 13 | Fs afero.Fs 14 | } 15 | -------------------------------------------------------------------------------- /tfrefactor/command/resource.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | 8 | "github.com/anGie44/ohmyhcl/tfrefactor/tfrefactor" 9 | flag "github.com/spf13/pflag" 10 | ) 11 | 12 | type ResourceCommand struct { 13 | Meta 14 | typ string 15 | providerVersion string 16 | path string 17 | csv bool 18 | recursive bool 19 | ignoreArguments []string 20 | ignoreResourceNames []string 21 | ignorePaths []string 22 | } 23 | 24 | func (r *ResourceCommand) Run(args []string) int { 25 | cmdFlags := flag.NewFlagSet("resource", flag.ContinueOnError) 26 | cmdFlags.StringVarP(&r.providerVersion, "provider-version", "p", "latest", "A new provider version constraint") 27 | cmdFlags.BoolVarP(&r.csv, "csv", "c", false, "Generate .csv file with list of new resources and their parent resource") 28 | cmdFlags.BoolVarP(&r.recursive, "recursive", "r", false, "Check a directory recursively") 29 | cmdFlags.StringSliceVarP(&r.ignoreArguments, "ignore-arguments", "", []string{}, "Arguments to ignore") 30 | cmdFlags.StringSliceVarP(&r.ignoreResourceNames, "ignore-names", "", []string{}, "Specific resource names to ignore") 31 | cmdFlags.StringSliceVarP(&r.ignorePaths, "ignore-paths", "i", []string{}, "A regular expression for paths to ignore") 32 | 33 | if err := cmdFlags.Parse(args); err != nil { 34 | r.UI.Error(fmt.Sprintf("failed to parse CLI arguments: %s", err)) 35 | return 1 36 | } 37 | 38 | if len(cmdFlags.Args()) != 2 { //nolint:gomnd 39 | r.UI.Error(fmt.Sprintf("The command expects 2 arguments, but got %d", len(cmdFlags.Args()))) 40 | r.UI.Error(r.Help()) 41 | return 1 42 | } 43 | 44 | r.typ = cmdFlags.Arg(0) 45 | r.path = cmdFlags.Arg(1) 46 | 47 | log.Printf("[INFO] Migrate resources of type %s to provider version %s", r.typ, r.providerVersion) 48 | option, err := tfrefactor.NewOption("resource", r.typ, r.providerVersion, r.csv, r.recursive, r.ignoreArguments, r.ignoreResourceNames, r.ignorePaths) 49 | if err != nil { 50 | r.UI.Error(err.Error()) 51 | return 1 52 | } 53 | 54 | log.Printf("[INFO] Migrating file or dir at path: %s", r.path) 55 | 56 | err = tfrefactor.MigrateFileOrDir(r.Fs, r.path, option) 57 | if err != nil { 58 | r.UI.Error(err.Error()) 59 | return 1 60 | } 61 | 62 | return 0 63 | } 64 | 65 | // Help returns long-form help text. 66 | func (r *ResourceCommand) Help() string { 67 | helpText := ` 68 | Usage: tfrefactor resource [options] 69 | Arguments 70 | RESOURCE_TYPE The provider resource type (e.g. aws_s3_bucket) 71 | PATH A path of file or directory to update 72 | Options: 73 | --ignore-arguments The arguments in the to ignore 74 | Set the flag with values separated by commas (e.g. --ignore-arguments="acl,grant") or set the flag multiple times. 75 | --ignore-names The resource names of to ignore 76 | Set the flag with values separated by commas (e.g. --ignore-names="example,log_bucket") or set the flag multiple times. 77 | -i --ignore-paths Regular expressions for path to ignore 78 | Set the flag with values separated by commas or set the flag multiple times. 79 | -c --csv Generate a CSV file of new resources and their parent resource (default: false) 80 | -p --provider-version The provider version constraint (default: v4.0.0) 81 | -r --recursive Check a directory recursively (default: false) 82 | ` 83 | return strings.TrimSpace(helpText) 84 | } 85 | 86 | // Synopsis returns one-line help text. 87 | func (r *ResourceCommand) Synopsis() string { 88 | return "Refactor resource arguments to individual resources" 89 | } 90 | -------------------------------------------------------------------------------- /tfrefactor/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/anGie44/ohmyhcl/tfrefactor 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/aws/aws-sdk-go v1.42.52 7 | github.com/hashicorp/go-multierror v1.1.1 8 | github.com/hashicorp/hcl/v2 v2.11.1 9 | github.com/hashicorp/logutils v1.0.0 10 | github.com/minamijoyo/tfupdate v0.6.4 11 | github.com/mitchellh/cli v1.1.2 12 | github.com/pkg/errors v0.9.1 13 | github.com/spf13/afero v1.8.1 14 | github.com/spf13/pflag v1.0.5 15 | github.com/zclconf/go-cty v1.10.0 16 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c 17 | ) 18 | 19 | require ( 20 | github.com/Masterminds/goutils v1.1.0 // indirect 21 | github.com/Masterminds/semver v1.5.0 // indirect 22 | github.com/Masterminds/sprig v2.22.0+incompatible // indirect 23 | github.com/agext/levenshtein v1.2.1 // indirect 24 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 25 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect 26 | github.com/bgentry/speakeasy v0.1.0 // indirect 27 | github.com/fatih/color v1.7.0 // indirect 28 | github.com/google/go-cmp v0.5.7 // indirect 29 | github.com/google/uuid v1.1.2 // indirect 30 | github.com/hashicorp/errwrap v1.0.0 // indirect 31 | github.com/huandu/xstrings v1.3.2 // indirect 32 | github.com/imdario/mergo v0.3.12 // indirect 33 | github.com/jmespath/go-jmespath v0.4.0 // indirect 34 | github.com/kr/pretty v0.2.1 // indirect 35 | github.com/kr/text v0.2.0 // indirect 36 | github.com/mattn/go-colorable v0.0.9 // indirect 37 | github.com/mattn/go-isatty v0.0.3 // indirect 38 | github.com/mitchellh/copystructure v1.2.0 // indirect 39 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect 40 | github.com/mitchellh/reflectwalk v1.0.2 // indirect 41 | github.com/posener/complete v1.1.1 // indirect 42 | github.com/sergi/go-diff v1.2.0 // indirect 43 | golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect 44 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect 45 | golang.org/x/text v0.3.6 // indirect 46 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect 47 | ) 48 | -------------------------------------------------------------------------------- /tfrefactor/go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 5 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 6 | cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 7 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 8 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 9 | cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= 10 | cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= 11 | cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= 12 | cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= 13 | cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= 14 | cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= 15 | cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= 16 | cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= 17 | cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= 18 | cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= 19 | cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= 20 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 21 | cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= 22 | cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= 23 | cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= 24 | cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= 25 | cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= 26 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 27 | cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= 28 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 29 | cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= 30 | cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= 31 | cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= 32 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 33 | cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= 34 | cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= 35 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 36 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= 37 | cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= 38 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 39 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 40 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 41 | github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= 42 | github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= 43 | github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= 44 | github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= 45 | github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= 46 | github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= 47 | github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= 48 | github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 49 | github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= 50 | github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= 51 | github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 52 | github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= 53 | github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= 54 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= 55 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 56 | github.com/aws/aws-sdk-go v1.42.52 h1:/+TZ46+0qu9Ph/UwjVrU3SG8OBi87uJLrLiYRNZKbHQ= 57 | github.com/aws/aws-sdk-go v1.42.52/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= 58 | github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= 59 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 60 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 61 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 62 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 63 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 64 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 65 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 66 | github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 67 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 68 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 69 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 70 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 71 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 72 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 73 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 74 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 75 | github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= 76 | github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 77 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 78 | github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= 79 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 80 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 81 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 82 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 83 | github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= 84 | github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= 85 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 86 | github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 87 | github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 88 | github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 89 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 90 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 91 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 92 | github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 93 | github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 94 | github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= 95 | github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= 96 | github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 97 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 98 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 99 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 100 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 101 | github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 102 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 103 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 104 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 105 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 106 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 107 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 108 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 109 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 110 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 111 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 112 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 113 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 114 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 115 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 116 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 117 | github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 118 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 119 | github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 120 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 121 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 122 | github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= 123 | github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= 124 | github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM= 125 | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 126 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 127 | github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 128 | github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= 129 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 130 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 131 | github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 132 | github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 133 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 134 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 135 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= 136 | github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 137 | github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 138 | github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 139 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 140 | github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= 141 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 142 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 143 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 144 | github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= 145 | github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= 146 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 147 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 148 | github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= 149 | github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= 150 | github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 151 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 152 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 153 | github.com/hashicorp/hcl/v2 v2.10.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= 154 | github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= 155 | github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= 156 | github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= 157 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 158 | github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= 159 | github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= 160 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 161 | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 162 | github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 163 | github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= 164 | github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 165 | github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= 166 | github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= 167 | github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= 168 | github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= 169 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 170 | github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= 171 | github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= 172 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 173 | github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= 174 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 175 | github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= 176 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 177 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 178 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 179 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 180 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 181 | github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= 182 | github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= 183 | github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= 184 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 185 | github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= 186 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 187 | github.com/minamijoyo/tfupdate v0.6.4 h1:J/jjNM3p+UpjsOrgSxq2BuSKmIQKRHg4apb6J8Pc5Mc= 188 | github.com/minamijoyo/tfupdate v0.6.4/go.mod h1:x9sgnujSOep75cAIdXEMzqKsJW2FpZBT5dflwfyjPi4= 189 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 190 | github.com/mitchellh/cli v1.1.2 h1:PvH+lL2B7IQ101xQL63Of8yFS2y+aDlsFcsqNc+u/Kw= 191 | github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= 192 | github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= 193 | github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= 194 | github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= 195 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= 196 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 197 | github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 198 | github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= 199 | github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 200 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 201 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 202 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 203 | github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= 204 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 205 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 206 | github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= 207 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 208 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 209 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 210 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 211 | github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= 212 | github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 213 | github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= 214 | github.com/spf13/afero v1.8.1 h1:izYHOT71f9iZ7iq37Uqjael60/vYC6vMtzedudZ0zEk= 215 | github.com/spf13/afero v1.8.1/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= 216 | github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 217 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 218 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 219 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 220 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 221 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 222 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 223 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 224 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 225 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 226 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 227 | github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= 228 | github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= 229 | github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= 230 | github.com/xanzy/go-gitlab v0.20.1/go.mod h1:LSfUQ9OPDnwRqulJk2HcWaAiFfCzaknyeGvjQI67MbE= 231 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 232 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 233 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 234 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 235 | github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= 236 | github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= 237 | github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= 238 | github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= 239 | github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= 240 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 241 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 242 | go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 243 | go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 244 | go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 245 | go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= 246 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 247 | golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 248 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 249 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 250 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 251 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 252 | golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 253 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 254 | golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4= 255 | golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 256 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 257 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 258 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 259 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 260 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 261 | golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 262 | golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 263 | golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= 264 | golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= 265 | golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= 266 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 267 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 268 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 269 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 270 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 271 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 272 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 273 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 274 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 275 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= 276 | golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 277 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 278 | golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 279 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 280 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 281 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 282 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 283 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 284 | golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 285 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 286 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 287 | golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 288 | golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 289 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 290 | golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 291 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 292 | golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 293 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 294 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 295 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 296 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 297 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 298 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 299 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 300 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 301 | golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 302 | golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 303 | golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 304 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 305 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 306 | golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 307 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 308 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 309 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 310 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 311 | golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 312 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 313 | golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 314 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 315 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 316 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 317 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 318 | golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 319 | golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 320 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 321 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 322 | golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM= 323 | golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 324 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 325 | golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 326 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 327 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 328 | golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 329 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 330 | golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 331 | golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 332 | golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 333 | golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 334 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 335 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 336 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 337 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 338 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 339 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 340 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 341 | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 342 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 343 | golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 344 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 345 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 346 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 347 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 348 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 349 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 350 | golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 351 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 352 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 353 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 354 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 355 | golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 356 | golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 357 | golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 358 | golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 359 | golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 360 | golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 361 | golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 362 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 363 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 364 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 365 | golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 366 | golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 367 | golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 368 | golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 369 | golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 370 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 371 | golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 372 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 373 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 374 | golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 375 | golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 376 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 377 | golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 378 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 379 | golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 380 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= 381 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 382 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 383 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 384 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 385 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 386 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 387 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 388 | golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 389 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 390 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 391 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 392 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 393 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 394 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 395 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 396 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 397 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 398 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 399 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 400 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 401 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 402 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 403 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 404 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 405 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 406 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 407 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 408 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 409 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 410 | golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 411 | golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 412 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 413 | golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 414 | golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 415 | golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 416 | golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 417 | golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 418 | golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 419 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 420 | golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 421 | golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 422 | golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 423 | golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 424 | golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 425 | golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 426 | golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= 427 | golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= 428 | golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 429 | golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 430 | golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 431 | golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 432 | golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 433 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 434 | golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 435 | golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= 436 | golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 437 | golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 438 | golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 439 | golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 440 | golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 441 | golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= 442 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 443 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 444 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 445 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 446 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 447 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 448 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 449 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 450 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 451 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 452 | google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 453 | google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 454 | google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 455 | google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 456 | google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 457 | google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 458 | google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= 459 | google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 460 | google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= 461 | google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= 462 | google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= 463 | google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= 464 | google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= 465 | google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= 466 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 467 | google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 468 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 469 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 470 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 471 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 472 | google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 473 | google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 474 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 475 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 476 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 477 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 478 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 479 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 480 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 481 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 482 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 483 | google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 484 | google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 485 | google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 486 | google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 487 | google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 488 | google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= 489 | google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 490 | google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 491 | google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 492 | google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 493 | google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 494 | google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 495 | google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 496 | google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 497 | google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= 498 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 499 | google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= 500 | google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 501 | google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 502 | google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 503 | google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 504 | google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 505 | google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 506 | google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 507 | google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 508 | google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 509 | google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 510 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 511 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 512 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 513 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 514 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 515 | google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 516 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 517 | google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 518 | google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= 519 | google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= 520 | google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 521 | google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 522 | google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= 523 | google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= 524 | google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= 525 | google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 526 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 527 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 528 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 529 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 530 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 531 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 532 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 533 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 534 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 535 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 536 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 537 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 538 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 539 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 540 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 541 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 542 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 543 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 544 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 545 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 546 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 547 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 548 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 549 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 550 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 551 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 552 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 553 | honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 554 | honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= 555 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 556 | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= 557 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 558 | -------------------------------------------------------------------------------- /tfrefactor/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | "log" 8 | "os" 9 | "strings" 10 | 11 | "github.com/anGie44/ohmyhcl/tfrefactor/command" 12 | "github.com/hashicorp/logutils" 13 | "github.com/mitchellh/cli" 14 | "github.com/spf13/afero" 15 | ) 16 | 17 | var UI cli.Ui 18 | 19 | func init() { 20 | UI = &cli.BasicUi{ 21 | Writer: os.Stdout, 22 | } 23 | } 24 | 25 | func main() { 26 | log.SetOutput(logOutput()) 27 | log.Printf("[INFO] CLI args: %#v", os.Args) 28 | 29 | commands := initCommands() 30 | 31 | args := os.Args[1:] 32 | 33 | c := &cli.CLI{ 34 | Name: "tfrefactor", 35 | Args: args, 36 | Commands: commands, 37 | HelpWriter: os.Stdout, 38 | Autocomplete: true, 39 | AutocompleteInstall: "install-autocomplete", 40 | AutocompleteUninstall: "uninstall-autocomplete", 41 | } 42 | 43 | exitStatus, err := c.Run() 44 | if err != nil { 45 | UI.Error(fmt.Sprintf("Failed to execute CLI: %s", err)) 46 | } 47 | 48 | os.Exit(exitStatus) 49 | } 50 | 51 | func logOutput() io.Writer { 52 | levels := []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"} 53 | minLevel := os.Getenv("TFREFACTOR_LOG") 54 | 55 | // default log writer is null device. 56 | writer := ioutil.Discard 57 | if minLevel != "" { 58 | writer = os.Stderr 59 | } 60 | 61 | filter := &logutils.LevelFilter{ 62 | Levels: levels, 63 | MinLevel: logutils.LogLevel(strings.ToUpper(minLevel)), 64 | Writer: writer, 65 | } 66 | 67 | return filter 68 | } 69 | 70 | func initCommands() map[string]cli.CommandFactory { 71 | meta := command.Meta{ 72 | UI: UI, 73 | Fs: afero.NewOsFs(), 74 | } 75 | 76 | commands := map[string]cli.CommandFactory{ 77 | "resource": func() (cli.Command, error) { 78 | return &command.ResourceCommand{ 79 | Meta: meta, 80 | }, nil 81 | }, 82 | } 83 | 84 | return commands 85 | } 86 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/enum.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import "fmt" 4 | 5 | type Resource int64 6 | 7 | var ResourceMap map[string]string 8 | 9 | const ( 10 | AccelerationStatus = "acceleration_status" 11 | Acl = "acl" 12 | AccelerateConfiguration = "accelerate_configuration" 13 | CorsConfiguration = "cors_configuration" 14 | CorsRule = "cors_rule" 15 | Grant = "grant" 16 | LifecycleConfiguration = "lifecycle_configuration" 17 | LifecycleRule = "lifecycle_rule" 18 | Logging = "logging" 19 | ObjectLockConfiguration = "object_lock_configuration" 20 | Policy = "policy" 21 | ReplicationConfiguration = "replication_configuration" 22 | RequestPayer = "request_payer" 23 | RequestPaymentConfiguration = "request_payment_configuration" 24 | ServerSideEncryptionConfiguration = "server_side_encryption_configuration" 25 | Versioning = "versioning" 26 | Website = "website" 27 | WebsiteConfiguration = "website_configuration" 28 | 29 | ResourceTypeAwsS3Bucket = "aws_s3_bucket" 30 | ResourceTypeAwsS3BucketAccelerateConfiguration Resource = iota 31 | ResourceTypeAwsS3BucketAcl 32 | ResourceTypeAwsS3BucketCorsConfiguration 33 | ResourceTypeAwsS3BucketLifecycleConfiguration 34 | ResourceTypeAwsS3BucketLogging 35 | ResourceTypeAwsS3BucketObjectLockConfiguration 36 | ResourceTypeAwsS3BucketPolicy 37 | ResourceTypeAwsS3BucketReplicationConfiguration 38 | ResourceTypeAwsS3BucketRequestPaymentConfiguration 39 | ResourceTypeAwsS3BucketServerSideEncryptionConfiguration 40 | ResourceTypeAwsS3BucketVersioning 41 | ResourceTypeAwsS3BucketWebsiteConfiguration 42 | ) 43 | 44 | func (r Resource) String() string { 45 | switch r { 46 | case ResourceTypeAwsS3BucketAccelerateConfiguration: 47 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, AccelerateConfiguration) 48 | case ResourceTypeAwsS3BucketAcl: 49 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, Acl) 50 | case ResourceTypeAwsS3BucketCorsConfiguration: 51 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, CorsConfiguration) 52 | case ResourceTypeAwsS3BucketLifecycleConfiguration: 53 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, LifecycleConfiguration) 54 | case ResourceTypeAwsS3BucketLogging: 55 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, Logging) 56 | case ResourceTypeAwsS3BucketObjectLockConfiguration: 57 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, ObjectLockConfiguration) 58 | case ResourceTypeAwsS3BucketPolicy: 59 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, Policy) 60 | case ResourceTypeAwsS3BucketReplicationConfiguration: 61 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, ReplicationConfiguration) 62 | case ResourceTypeAwsS3BucketRequestPaymentConfiguration: 63 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, RequestPaymentConfiguration) 64 | case ResourceTypeAwsS3BucketServerSideEncryptionConfiguration: 65 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, ServerSideEncryptionConfiguration) 66 | case ResourceTypeAwsS3BucketVersioning: 67 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, Versioning) 68 | case ResourceTypeAwsS3BucketWebsiteConfiguration: 69 | return fmt.Sprintf("%s_%s", ResourceTypeAwsS3Bucket, WebsiteConfiguration) 70 | } 71 | return "unknown" 72 | } 73 | 74 | func init() { 75 | ResourceMap = make(map[string]string) 76 | ResourceMap["acceleration_status"] = ResourceTypeAwsS3BucketAccelerateConfiguration.String() 77 | ResourceMap["acl"] = ResourceTypeAwsS3BucketAcl.String() 78 | ResourceMap["grant"] = ResourceTypeAwsS3BucketAcl.String() 79 | ResourceMap["policy"] = ResourceTypeAwsS3BucketPolicy.String() 80 | ResourceMap["request_payer"] = ResourceTypeAwsS3BucketRequestPaymentConfiguration.String() 81 | } 82 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/file.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "strings" 10 | 11 | "github.com/hashicorp/hcl/v2/hclwrite" 12 | "github.com/spf13/afero" 13 | ) 14 | 15 | // Note: This file and its methods are taken from https://github.com/minamijoyo/tfupdate/blob/master/tfupdate/file.go 16 | // with the exception that they are renamed with the "Migrate" prefix 17 | 18 | // MigrateFile migrates resources in a new single file. 19 | // Optionally will generate a resulting CSV with the new resources and their parent. 20 | // We use an afero filesystem here for testing. 21 | func MigrateFile(fs afero.Fs, filename string, o Option) error { 22 | log.Printf("[DEBUG] check file: %s", filename) 23 | r, err := fs.Open(filename) 24 | if err != nil { 25 | return fmt.Errorf("[ERROR] failed to open file: %s", err) 26 | } 27 | defer r.Close() 28 | 29 | w := &bytes.Buffer{} 30 | newResourceNames, err := MigrateHCL(r, w, filename, o) 31 | if err != nil { 32 | return err 33 | } 34 | 35 | // Write contents to destination file if migrations occurred. 36 | if len(newResourceNames) == 0 { 37 | log.Printf("[DEBUG] no migration file to create for %s", filename) 38 | return nil 39 | } 40 | 41 | outputFilename := strings.Replace(filename, ".tf", "_migrated.tf", 1) 42 | log.Printf("[INFO] new file: %s", outputFilename) 43 | migrated := w.Bytes() 44 | // We should be able to choose whether to format output or not. 45 | // However, the current implementation of (*hclwrite.Body).SetAttributeValue() 46 | // does not seem to preserve an original SpaceBefore value of attribute. 47 | // So, we need to format output here. 48 | result := hclwrite.Format(migrated) 49 | if err = afero.WriteFile(fs, outputFilename, result, 0644); err != nil { 50 | return fmt.Errorf("failed to write file: %s", err) 51 | } 52 | 53 | // Write migrations to csv file 54 | if o.Csv { 55 | newFile, err := os.Create(strings.Replace(filename, ".tf", "_new_resources.csv", 1)) 56 | log.Printf("[INFO] new file: %s", newFile.Name()) 57 | if err != nil { 58 | return fmt.Errorf("[ERROR] error creating (%s): %s", newFile.Name(), err) 59 | } 60 | 61 | defer newFile.Close() 62 | 63 | for _, r := range newResourceNames { 64 | if _, err := newFile.WriteString(fmt.Sprintf("%s\n", r)); err != nil { 65 | log.Printf("[ERROR] error writing (%s) to file (%s): %s", r, newFile.Name(), err) 66 | } 67 | } 68 | } 69 | 70 | return nil 71 | } 72 | 73 | // MigrateDir migrates resources for files in a given directory. 74 | // If a recursive flag is true, it checks and migrates recursively. 75 | // skip hidden directories such as .terraform or .git. 76 | // It also skips a file without .tf extension. 77 | func MigrateDir(fs afero.Fs, dirname string, o Option) error { 78 | log.Printf("[DEBUG] check dir: %s", dirname) 79 | dir, err := afero.ReadDir(fs, dirname) 80 | if err != nil { 81 | return fmt.Errorf("failed to open dir: %s", err) 82 | } 83 | 84 | for _, entry := range dir { 85 | path := filepath.Join(dirname, entry.Name()) 86 | 87 | // if a path of entry matches ignorePaths, skip it. 88 | if o.MatchIgnorePaths(path) { 89 | log.Printf("[DEBUG] ignore: %s", path) 90 | continue 91 | } 92 | 93 | if entry.IsDir() { 94 | // if an entry is a directory 95 | if !o.Recursive { 96 | // skip directory if a recursive flag is false 97 | continue 98 | } 99 | if strings.HasPrefix(entry.Name(), ".") { 100 | // skip hidden directories such as .terraform or .git 101 | continue 102 | } 103 | 104 | err := MigrateDir(fs, path, o) 105 | if err != nil { 106 | return err 107 | } 108 | 109 | continue 110 | } 111 | 112 | // if an entry is a file 113 | if filepath.Ext(entry.Name()) != ".tf" { 114 | // skip a file without .tf extension. 115 | continue 116 | } 117 | 118 | err := MigrateFile(fs, path, o) 119 | if err != nil { 120 | return err 121 | } 122 | } 123 | return nil 124 | } 125 | 126 | // MigrateFileOrDir updates version constraints in a given file or directory. 127 | func MigrateFileOrDir(fs afero.Fs, path string, o Option) error { 128 | isDir, err := afero.IsDir(fs, path) 129 | if err != nil { 130 | return fmt.Errorf("failed to open path: %s", err) 131 | } 132 | 133 | if isDir { 134 | // if an entry is a directory 135 | return MigrateDir(fs, path, o) 136 | } 137 | 138 | // if an entry is a file 139 | return MigrateFile(fs, path, o) 140 | } 141 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/file_test.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | 8 | "github.com/spf13/afero" 9 | ) 10 | 11 | func TestMigrateFileExist(t *testing.T) { 12 | cases := []struct { 13 | name string 14 | filename string 15 | src string 16 | o Option 17 | want string 18 | expectedErr error 19 | expectedMigrationFilename string 20 | }{ 21 | { 22 | filename: "valid.tf", 23 | src: ` 24 | terraform { 25 | required_providers { 26 | aws = { 27 | version = "3.74.0" 28 | } 29 | } 30 | } 31 | 32 | resource "aws_s3_bucket" "test" { 33 | bucket = "tf-acc-test-1234" 34 | acl = "private" 35 | } 36 | `, 37 | o: Option{ 38 | MigratorType: "resource", 39 | ResourceType: ResourceTypeAwsS3Bucket, 40 | }, 41 | expectedMigrationFilename: "valid_migrated.tf", 42 | want: ` 43 | terraform { 44 | required_providers { 45 | aws = { 46 | version = "3.74.0" 47 | } 48 | } 49 | } 50 | 51 | resource "aws_s3_bucket" "test" { 52 | bucket = "tf-acc-test-1234" 53 | } 54 | 55 | resource "aws_s3_bucket_acl" "test_acl" { 56 | bucket = aws_s3_bucket.test.id 57 | acl = "private" 58 | } 59 | `, 60 | }, 61 | { 62 | filename: "valid.tf", 63 | src: ` 64 | terraform { 65 | required_providers { 66 | aws = { 67 | version = "3.74.0" 68 | } 69 | } 70 | } 71 | 72 | resource "aws_s3_bucket" "test" { 73 | bucket = "tf-acc-test-1234" 74 | acl = "private" 75 | } 76 | `, 77 | o: Option{ 78 | MigratorType: "resource", 79 | ProviderVersion: "latest", 80 | ResourceType: ResourceTypeAwsS3Bucket, 81 | }, 82 | expectedMigrationFilename: "valid_migrated.tf", 83 | want: ` 84 | terraform { 85 | required_providers { 86 | aws = { 87 | version = "4.0.0" 88 | } 89 | } 90 | } 91 | 92 | resource "aws_s3_bucket" "test" { 93 | bucket = "tf-acc-test-1234" 94 | } 95 | 96 | resource "aws_s3_bucket_acl" "test_acl" { 97 | bucket = aws_s3_bucket.test.id 98 | acl = "private" 99 | } 100 | `, 101 | }, 102 | { 103 | filename: "valid.tf", 104 | src: ` 105 | terraform { 106 | required_providers { 107 | aws = { 108 | version = "3.74.0" 109 | } 110 | } 111 | } 112 | 113 | resource "aws_s3_bucket" "test" { 114 | bucket = "tf-acc-test-1234" 115 | acl = "private" 116 | } 117 | `, 118 | o: Option{ 119 | MigratorType: "resource", 120 | ProviderVersion: "4.1.0", 121 | ResourceType: ResourceTypeAwsS3Bucket, 122 | }, 123 | expectedMigrationFilename: "valid_migrated.tf", 124 | want: ` 125 | terraform { 126 | required_providers { 127 | aws = { 128 | version = "4.1.0" 129 | } 130 | } 131 | } 132 | 133 | resource "aws_s3_bucket" "test" { 134 | bucket = "tf-acc-test-1234" 135 | } 136 | 137 | resource "aws_s3_bucket_acl" "test_acl" { 138 | bucket = aws_s3_bucket.test.id 139 | acl = "private" 140 | } 141 | `, 142 | }, 143 | { 144 | filename: "unformatted_mo_match.tf", 145 | src: ` 146 | terraform { 147 | required_providers { 148 | aws = "3.74.0" 149 | } 150 | } 151 | 152 | resource "aws_s3_bucket" "test" { 153 | bucket = "tf-acc-test-1234" 154 | } 155 | `, 156 | o: Option{ 157 | MigratorType: "resource", 158 | ResourceType: ResourceTypeAwsS3Bucket, 159 | ProviderVersion: "latest", 160 | }, 161 | }, 162 | } 163 | for _, tc := range cases { 164 | fs := afero.NewMemMapFs() 165 | err := afero.WriteFile(fs, tc.filename, []byte(tc.src), 0644) 166 | if err != nil { 167 | t.Fatalf("failed to write file: %s", err) 168 | } 169 | 170 | err = MigrateFile(fs, tc.filename, tc.o) 171 | if tc.expectedErr == nil && err != nil { 172 | t.Errorf("MigrateFile() with filename = %s, o = %#v returns unexpected err: %+v", tc.filename, tc.o, err) 173 | } 174 | 175 | if tc.expectedErr != nil && err == nil { 176 | t.Errorf("MigrateFile() with filename = %s, o = %#v expects to return an error, but no error", tc.filename, tc.o) 177 | } 178 | 179 | if tc.expectedMigrationFilename == "" { 180 | migrationFile := fmt.Sprintf("%s_migrated.tf", tc.filename) 181 | if _, err := os.Stat(migrationFile); err == nil { 182 | t.Errorf("MigrateFile() with no migrations expects to return no migration file, but found migration file: %s", migrationFile) 183 | } 184 | } 185 | 186 | if tc.expectedMigrationFilename != "" { 187 | got, err := afero.ReadFile(fs, tc.expectedMigrationFilename) 188 | if err != nil { 189 | t.Fatalf("failed to read migration file: %s", err) 190 | } 191 | 192 | if string(got) != tc.want { 193 | t.Errorf("MigrateFile() with filename = %s, o = %#v returns %s, but want = %s", tc.filename, tc.o, string(got), tc.want) 194 | } 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/migrate.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | 8 | "github.com/hashicorp/go-multierror" 9 | "github.com/hashicorp/hcl/v2" 10 | "github.com/hashicorp/hcl/v2/hclwrite" 11 | "github.com/minamijoyo/tfupdate/tfupdate" 12 | "github.com/pkg/errors" 13 | ) 14 | 15 | const v4 = "4.0.0" 16 | 17 | type Migrator interface { 18 | Migrate(file *hclwrite.File) error 19 | Migrations() []string 20 | } 21 | 22 | func NewMigrator(o Option) (Migrator, error) { 23 | switch o.MigratorType { 24 | case "resource": 25 | switch o.ResourceType { 26 | case "aws_s3_bucket": 27 | return NewProviderAwsS3BucketMigrator(o.IgnoreArguments, o.IgnoreResourceNames) 28 | default: 29 | return nil, errors.Errorf("failed to create new migrator. unknown resource type: %s", o.ResourceType) 30 | } 31 | default: 32 | return nil, errors.Errorf("failed to create new migrator. unknown type: %s", o.MigratorType) 33 | } 34 | } 35 | 36 | func MigrateHCL(r io.Reader, w io.Writer, filename string, o Option) ([]string, error) { 37 | input, err := ioutil.ReadAll(r) 38 | if err != nil { 39 | return nil, fmt.Errorf("failed to read input: %s", err) 40 | } 41 | 42 | f, diags := hclwrite.ParseConfig(input, filename, hcl.Pos{Line: 1, Column: 1}) 43 | if diags != nil { 44 | var errs *multierror.Error 45 | for _, diag := range diags { 46 | if diag.Error() != "" { 47 | errs = multierror.Append(errs, fmt.Errorf(diag.Error())) 48 | } 49 | } 50 | return nil, errs.ErrorOrNil() 51 | } 52 | 53 | // Migrate Provider Version(s) 54 | if o.ProviderVersion != "" { 55 | if o.ProviderVersion == "latest" { 56 | o.ProviderVersion = v4 57 | } 58 | 59 | p, err := tfupdate.NewProviderUpdater("aws", o.ProviderVersion) 60 | if err != nil { 61 | return nil, fmt.Errorf("error creating tfupdate.ProviderUpdater: %w", err) 62 | } 63 | 64 | if err := p.Update(f); err != nil { 65 | return nil, fmt.Errorf("error updating provider configurations to %s: %s", o.ProviderVersion, err) 66 | } 67 | } 68 | 69 | m, err := NewMigrator(o) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | if err = m.Migrate(f); err != nil { 75 | return m.Migrations(), err 76 | } 77 | 78 | output := f.BuildTokens(nil).Bytes() 79 | 80 | if _, err := w.Write(output); err != nil { 81 | return m.Migrations(), fmt.Errorf("failed to write output: %s", err) 82 | } 83 | 84 | return m.Migrations(), nil 85 | } 86 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/option.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | ) 7 | 8 | // Option is a set of parameters to migrate. 9 | type Option struct { 10 | MigratorType string 11 | 12 | // ResourceType to migrate e.g. aws_s3_bucket 13 | ResourceType string 14 | 15 | // a new provider version constraint 16 | ProviderVersion string 17 | 18 | // If a csv flag is true, generates additional CSV file of new resources and their parent S3 bucket 19 | Csv bool 20 | 21 | // If a recursive flag is true, it checks and updates directories recursively. 22 | Recursive bool 23 | 24 | // An array of arguments to ignore 25 | IgnoreArguments []string 26 | 27 | // An array of resource names to ignore 28 | IgnoreResourceNames []string 29 | 30 | // An array of regular expression for paths to ignore. 31 | IgnorePaths []*regexp.Regexp 32 | } 33 | 34 | // NewOption returns an option. 35 | func NewOption(migratorType, resourceType, providerVersion string, csv, recursive bool, ignoreArguments, ignoreResourceNames, ignorePaths []string) (Option, error) { 36 | regexps := make([]*regexp.Regexp, 0, len(ignorePaths)) 37 | for _, ignorePath := range ignorePaths { 38 | if len(ignorePath) == 0 { 39 | continue 40 | } 41 | 42 | r, err := regexp.Compile(ignorePath) 43 | if err != nil { 44 | return Option{}, fmt.Errorf("faild to compile regexp for ignorePath: %s", err) 45 | } 46 | regexps = append(regexps, r) 47 | } 48 | 49 | return Option{ 50 | MigratorType: migratorType, 51 | ResourceType: resourceType, 52 | ProviderVersion: providerVersion, 53 | Csv: csv, 54 | Recursive: recursive, 55 | IgnoreArguments: ignoreArguments, 56 | IgnoreResourceNames: ignoreResourceNames, 57 | IgnorePaths: regexps, 58 | }, nil 59 | } 60 | 61 | // MatchIgnorePaths returns whether any of the ignore conditions are met. 62 | func (o *Option) MatchIgnorePaths(path string) bool { 63 | for _, r := range o.IgnorePaths { 64 | if r.MatchString(path) { 65 | return true 66 | } 67 | } 68 | 69 | return false 70 | } 71 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/s3_bucket.go: -------------------------------------------------------------------------------- 1 | package tfrefactor 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "gopkg.in/yaml.v3" 7 | "log" 8 | "strings" 9 | 10 | "github.com/aws/aws-sdk-go/aws" 11 | "github.com/aws/aws-sdk-go/service/s3" 12 | "github.com/hashicorp/hcl/v2" 13 | "github.com/hashicorp/hcl/v2/hclsyntax" 14 | "github.com/hashicorp/hcl/v2/hclwrite" 15 | "github.com/zclconf/go-cty/cty" 16 | ) 17 | 18 | type ProviderAwsS3BucketMigrator struct { 19 | ignoreArguments []string 20 | ignoreResourceNames []string 21 | newResourceNames []string 22 | } 23 | 24 | func NewProviderAwsS3BucketMigrator(ignoreArguments, ignoreResourceNames []string) (Migrator, error) { 25 | return &ProviderAwsS3BucketMigrator{ 26 | ignoreArguments: ignoreArguments, 27 | ignoreResourceNames: ignoreResourceNames, 28 | }, nil 29 | } 30 | 31 | func (m *ProviderAwsS3BucketMigrator) SkipResourceName(resourceName string) bool { 32 | if m == nil { 33 | return false 34 | } 35 | 36 | if len(m.ignoreResourceNames) == 0 { 37 | return false 38 | } 39 | 40 | for _, rn := range m.ignoreResourceNames { 41 | if rn == resourceName { 42 | return true 43 | } 44 | } 45 | 46 | return false 47 | } 48 | 49 | func (m *ProviderAwsS3BucketMigrator) SkipArgument(arg string) bool { 50 | if m == nil { 51 | return false 52 | } 53 | 54 | if len(m.ignoreArguments) == 0 { 55 | return false 56 | } 57 | 58 | for _, argument := range m.ignoreArguments { 59 | if argument == arg { 60 | return true 61 | } 62 | } 63 | 64 | return false 65 | } 66 | 67 | func (m *ProviderAwsS3BucketMigrator) Migrate(f *hclwrite.File) error { 68 | if err := m.migrateS3BucketResources(f); err != nil { 69 | return err 70 | } 71 | 72 | return nil 73 | } 74 | 75 | func (m *ProviderAwsS3BucketMigrator) Migrations() []string { 76 | if m == nil { 77 | return nil 78 | } 79 | return m.newResourceNames 80 | } 81 | 82 | func (m *ProviderAwsS3BucketMigrator) migrateS3BucketResources(f *hclwrite.File) error { 83 | if f == nil || f.Body() == nil { 84 | return fmt.Errorf("error migrating (%s) resources: empty file", ResourceTypeAwsS3Bucket) 85 | } 86 | 87 | for _, block := range f.Body().Blocks() { 88 | if block == nil { 89 | continue 90 | } 91 | 92 | labels := block.Labels() 93 | if len(labels) != 2 || labels[0] != ResourceTypeAwsS3Bucket { 94 | continue 95 | } 96 | 97 | if m.SkipResourceName(labels[1]) { 98 | continue 99 | } 100 | 101 | bucketPath := strings.Join(labels, ".") 102 | log.Printf("[INFO] Found %s\n", bucketPath) 103 | 104 | // Special Attribute Handling i.e. for_each and count 105 | countAttr := block.Body().GetAttribute("count") 106 | forEachAttr := block.Body().GetAttribute("for_each") 107 | 108 | /////////////////////////////////////////// Attribute Handling ///////////////////////////////////////////////// 109 | // 1. acceleration_status 110 | // 2. acl 111 | // 3. policy 112 | // 4. request_payer 113 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 114 | var aclResourceBlock *hclwrite.Block 115 | 116 | for k, v := range block.Body().Attributes() { 117 | if m.SkipArgument(k) { 118 | continue 119 | } 120 | switch k { 121 | case AccelerationStatus: 122 | block.Body().RemoveAttribute(k) 123 | f.Body().AppendNewline() 124 | 125 | newlabels := []string{ResourceMap[k], fmt.Sprintf("%s_%s", labels[1], AccelerateConfiguration)} 126 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 127 | 128 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 129 | hcl.TraverseRoot{ 130 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 131 | }, 132 | }) 133 | 134 | newBlock.Body().SetAttributeRaw("status", v.Expr().BuildTokens(nil)) 135 | 136 | log.Printf(" ✓ Created %s.%s", ResourceMap[k], newlabels[1]) 137 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceMap[k], newlabels[1], bucketPath)) 138 | case Acl, Policy: 139 | block.Body().RemoveAttribute(k) 140 | f.Body().AppendNewline() 141 | 142 | newlabels := []string{ResourceMap[k], fmt.Sprintf("%s_%s", labels[1], k)} 143 | aclResourceBlock = f.Body().AppendNewBlock(block.Type(), newlabels) 144 | 145 | aclResourceBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 146 | hcl.TraverseRoot{ 147 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 148 | }, 149 | }) 150 | 151 | aclResourceBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 152 | 153 | log.Printf(" ✓ Created %s.%s", ResourceMap[k], newlabels[1]) 154 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceMap[k], newlabels[1], bucketPath)) 155 | case RequestPayer: 156 | block.Body().RemoveAttribute(k) 157 | f.Body().AppendNewline() 158 | 159 | newlabels := []string{ResourceMap[k], fmt.Sprintf("%s_%s", labels[1], RequestPaymentConfiguration)} 160 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 161 | 162 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 163 | hcl.TraverseRoot{ 164 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 165 | }, 166 | }) 167 | 168 | newBlock.Body().SetAttributeRaw("payer", v.Expr().BuildTokens(nil)) 169 | 170 | log.Printf(" ✓ Created %s.%s", ResourceMap[k], newlabels[1]) 171 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceMap[k], newlabels[1], bucketPath)) 172 | } 173 | } 174 | 175 | ///////////////////////////////////////////// Block Handling /////////////////////////////////////////////////// 176 | // 1. Cors Rules 177 | // 2. Grants 178 | // 3. Lifecycle Rules 179 | // 4. Logging 180 | // 5. Object Lock Configuration 181 | // 6. Replication Configuration 182 | // 7. Server Side Encryption Configuration 183 | // 8. Website 184 | // 9. Versioning 185 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 186 | var corsRules []*hclwrite.Block 187 | var grants []*hclwrite.Block 188 | var lifecycleRules []*hclwrite.Block 189 | var logging *hclwrite.Block 190 | var objectLockConfig *hclwrite.Block 191 | var replicationConfig *hclwrite.Block 192 | var serverSideEncryptionConfig *hclwrite.Block 193 | var website *hclwrite.Block 194 | var versioning *hclwrite.Block 195 | 196 | for _, subBlock := range block.Body().Blocks() { 197 | if m.SkipArgument(subBlock.Type()) { 198 | continue 199 | } 200 | 201 | block.Body().RemoveBlock(subBlock) 202 | 203 | switch t := subBlock.Type(); t { 204 | case CorsRule: 205 | corsRules = append(corsRules, subBlock) 206 | case Grant: 207 | grants = append(grants, subBlock) 208 | case LifecycleRule: 209 | lifecycleRules = append(lifecycleRules, subBlock) 210 | case Logging: 211 | logging = subBlock 212 | case ObjectLockConfiguration: 213 | objectLockConfig = subBlock 214 | case ReplicationConfiguration: 215 | replicationConfig = subBlock 216 | case ServerSideEncryptionConfiguration: 217 | serverSideEncryptionConfig = subBlock 218 | case Versioning: 219 | versioning = subBlock 220 | case Website: 221 | website = subBlock 222 | case "dynamic": 223 | // TODO: Account for "dynamic" blocks ... yikes ... 224 | // Maybe we can recreate them ?? 225 | argument := subBlock.Labels()[0] // e.g. "website" 226 | 227 | forEachAttr := subBlock.Body().GetAttribute("for_each") 228 | 229 | for _, b := range subBlock.Body().Blocks() { 230 | // Expected: content 231 | if b.Type() != "content" { 232 | continue 233 | } 234 | 235 | switch argument { 236 | case CorsRule: 237 | // There can be many defined so we can maintain the dynamic block? 238 | corsRules = append(corsRules, subBlock) 239 | case Logging: 240 | // Set block with additional for_each data 241 | if forEachAttr != nil { 242 | b.Body().SetAttributeRaw("for_each", forEachAttr.Expr().BuildTokens(nil)) 243 | } 244 | logging = b 245 | case Website: 246 | // Set block with additional for_each data 247 | if forEachAttr != nil { 248 | b.Body().SetAttributeRaw("for_each", forEachAttr.Expr().BuildTokens(nil)) 249 | } 250 | website = b 251 | } 252 | } 253 | } 254 | } 255 | 256 | if len(corsRules) > 0 { 257 | // Create new Cors resource 258 | f.Body().AppendNewline() 259 | 260 | newlabels := []string{ResourceTypeAwsS3BucketCorsConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], CorsConfiguration)} 261 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 262 | 263 | for _, crBlock := range corsRules { 264 | if crBlock.Type() == "dynamic" { 265 | if forEach := crBlock.Body().GetAttribute("for_each"); forEach != nil { 266 | newBlock.Body().AppendUnstructuredTokens(hclwrite.Tokens{ 267 | { 268 | Type: hclsyntax.TokenComment, 269 | Bytes: []byte("# TODO: Replace with your intended 'for_each' value\n"), 270 | }, 271 | }) 272 | newBlock.Body().SetAttributeRaw("# for_each ", forEach.Expr().BuildTokens(nil)) 273 | } 274 | } 275 | } 276 | 277 | if countAttr != nil || forEachAttr != nil { 278 | newBlock.Body().AppendUnstructuredTokens(hclwrite.Tokens{ 279 | { 280 | Type: hclsyntax.TokenComment, 281 | Bytes: []byte(fmt.Sprintf(` 282 | # TODO: Replace 'bucket' argument value with correct instance index 283 | # e.g. aws_s3_bucket.%s[count.index].id 284 | `, labels[1])), 285 | }, 286 | }) 287 | } 288 | 289 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 290 | hcl.TraverseRoot{ 291 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 292 | }, 293 | }) 294 | 295 | for _, b := range corsRules { 296 | if b.Type() == "dynamic" { 297 | // Update content to use "each.value" 298 | for _, bb := range b.Body().Blocks() { 299 | if bb.Type() == "content" { 300 | for k, v := range bb.Body().Attributes() { 301 | bb.Body().SetAttributeTraversal(k, hcl.Traversal{ 302 | hcl.TraverseRoot{ 303 | Name: strings.Replace(string(v.Expr().BuildTokens(nil).Bytes()), "cors_rule.value", "each.value", 1), 304 | }, 305 | }) 306 | } 307 | } 308 | } 309 | } 310 | newBlock.Body().AppendBlock(b) 311 | } 312 | 313 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketCorsConfiguration, newlabels[1]) 314 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketCorsConfiguration, newlabels[1], bucketPath)) 315 | } 316 | 317 | if len(grants) > 0 { 318 | if aclResourceBlock == nil { 319 | // Create new aws_s3_bucket_acl resource 320 | f.Body().AppendNewline() 321 | 322 | newlabels := []string{ResourceTypeAwsS3BucketAcl.String(), fmt.Sprintf("%s_%s", labels[1], Acl)} 323 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 324 | 325 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 326 | hcl.TraverseRoot{ 327 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 328 | }, 329 | }) 330 | 331 | acpBlock := newBlock.Body().AppendNewBlock("access_control_policy", nil) 332 | 333 | for _, grant := range grants { 334 | grantBlock := acpBlock.Body().AppendNewBlock("grant", nil) 335 | grantee := grantBlock.Body().AppendNewBlock("grantee", nil) 336 | 337 | var permissions []string 338 | 339 | for k, v := range grant.Body().Attributes() { 340 | // Expected: id, type, uri, permissions 341 | if k == "permissions" { 342 | for _, t := range v.BuildTokens(nil) { 343 | if p := string(t.Bytes); len(p) > 1 && p != k { 344 | permissions = append(permissions, p) 345 | } 346 | } 347 | } else { 348 | grantee.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 349 | } 350 | } 351 | 352 | if len(permissions) == 0 { 353 | continue 354 | } 355 | 356 | grantBlock.Body().SetAttributeValue("permission", cty.StringVal(permissions[0])) 357 | 358 | if len(permissions) > 1 { 359 | // Create a new grant block for this permission 360 | for _, permission := range permissions[1:] { 361 | grantBlock := acpBlock.Body().AppendNewBlock("grant", nil) 362 | grantee := grantBlock.Body().AppendNewBlock("grantee", nil) 363 | 364 | for k, v := range grant.Body().Attributes() { 365 | if k == "permissions" { 366 | continue 367 | } 368 | grantee.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 369 | } 370 | 371 | grantBlock.Body().SetAttributeValue("permission", cty.StringVal(permission)) 372 | } 373 | } 374 | } 375 | 376 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketAcl, newlabels[1]) 377 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketAcl, newlabels[1], bucketPath)) 378 | } // TODO: Account for case where "acl" and "grant" are configured 379 | } 380 | 381 | if len(lifecycleRules) > 0 { 382 | f.Body().AppendNewline() 383 | 384 | newlabels := []string{ResourceTypeAwsS3BucketLifecycleConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], LifecycleConfiguration)} 385 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 386 | 387 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 388 | hcl.TraverseRoot{ 389 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 390 | }, 391 | }) 392 | 393 | for _, lifecycleRuleBlock := range lifecycleRules { 394 | ruleBlock := newBlock.Body().AppendNewBlock("rule", nil) 395 | 396 | m := make(map[string]*hclwrite.Attribute) 397 | 398 | for k, v := range lifecycleRuleBlock.Body().Attributes() { 399 | // Expected: id, prefix, tags, enabled, abort_incomplete_multipart_upload_days 400 | switch k { 401 | case "abort_incomplete_multipart_upload_days": 402 | // This is represented as a abort_incomplete_multipart_upload block in the new resource 403 | abortBlock := ruleBlock.Body().AppendNewBlock("abort_incomplete_multipart_upload", nil) 404 | abortBlock.Body().SetAttributeRaw("days_after_initiation", v.Expr().BuildTokens(nil)) 405 | case "enabled": 406 | // This is represented as "status" in the new resource 407 | value := strings.TrimSpace(string(v.Expr().BuildTokens(nil).Bytes())) 408 | if value == "true" { 409 | ruleBlock.Body().SetAttributeValue("status", cty.StringVal("Enabled")) 410 | } else if value == "false" { 411 | ruleBlock.Body().SetAttributeValue("status", cty.StringVal("Disabled")) 412 | } 413 | case "id": 414 | ruleBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 415 | case "prefix", "tags": 416 | m[k] = v 417 | } 418 | } 419 | 420 | if vTags, ok := m["tags"]; ok { 421 | filterBlock := ruleBlock.Body().AppendNewBlock("filter", nil) 422 | andBlock := filterBlock.Body().AppendNewBlock("and", nil) 423 | andBlock.Body().SetAttributeRaw("tags", vTags.Expr().BuildTokens(nil)) 424 | if vPrefix, vOk := m["prefix"]; vOk { 425 | andBlock.Body().SetAttributeRaw("prefix", vPrefix.Expr().BuildTokens(nil)) 426 | } else { 427 | andBlock.Body().SetAttributeValue("prefix", cty.StringVal("")) 428 | } 429 | } else if vPrefix, vOk := m["prefix"]; vOk { 430 | filterBlock := ruleBlock.Body().AppendNewBlock("filter", nil) 431 | filterBlock.Body().SetAttributeRaw("prefix", vPrefix.Expr().BuildTokens(nil)) 432 | } 433 | 434 | for _, b := range lifecycleRuleBlock.Body().Blocks() { 435 | // Expected: expiration, noncurrent_version_expiration, transition, noncurrent_version_transition 436 | switch b.Type() { 437 | case "expiration", "transition": 438 | ruleBlock.Body().AppendBlock(b) 439 | case "noncurrent_version_expiration": 440 | nve := ruleBlock.Body().AppendNewBlock("noncurrent_version_expiration", nil) 441 | for k, v := range b.Body().Attributes() { 442 | // Expected: days 443 | if k != "days" { 444 | continue 445 | } 446 | // "days" is represented as "noncurrent_days" in the new resource 447 | nve.Body().SetAttributeRaw("noncurrent_days", v.Expr().BuildTokens(nil)) 448 | } 449 | case "noncurrent_version_transition": 450 | nvt := ruleBlock.Body().AppendNewBlock("noncurrent_version_transition", nil) 451 | for k, v := range b.Body().Attributes() { 452 | // Expected: days, storage_class 453 | switch k { 454 | case "days": 455 | // "days" is represented as "noncurrent_days" in the new resource 456 | nvt.Body().SetAttributeRaw("noncurrent_days", v.Expr().BuildTokens(nil)) 457 | case "storage_class": 458 | nvt.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 459 | } 460 | } 461 | } 462 | } 463 | } 464 | 465 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketLifecycleConfiguration, newlabels[1]) 466 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketLifecycleConfiguration, newlabels[1], bucketPath)) 467 | } 468 | 469 | if logging != nil { 470 | f.Body().AppendNewline() 471 | 472 | newlabels := []string{ResourceTypeAwsS3BucketLogging.String(), fmt.Sprintf("%s_%s", labels[1], Logging)} 473 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 474 | 475 | // Account for dynamic blocks of this argument 476 | var hasForEach bool 477 | loggingForEachAttribute := logging.Body().GetAttribute("for_each") 478 | if loggingForEachAttribute != nil { 479 | hasForEach = true 480 | newBlock.Body().SetAttributeRaw("for_each", loggingForEachAttribute.Expr().BuildTokens(nil)) 481 | newBlock.Body().AppendNewline() 482 | } 483 | 484 | bucketAttribute := fmt.Sprintf("%s.%s.id", labels[0], labels[1]) 485 | 486 | if (countAttr != nil || forEachAttr != nil) && hasForEach { 487 | bucketAttribute = fmt.Sprintf("%s.%s[each.key].id", labels[0], labels[1]) 488 | } 489 | 490 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 491 | hcl.TraverseRoot{ 492 | Name: bucketAttribute, 493 | }, 494 | }) 495 | 496 | for k, v := range logging.Body().Attributes() { 497 | // Expected: target_bucket, target_prefix 498 | if hasForEach { 499 | val := strings.Replace(string(v.Expr().BuildTokens(nil).Bytes()), "logging.value", "each.value", 1) 500 | newBlock.Body().SetAttributeTraversal(k, hcl.Traversal{ 501 | hcl.TraverseRoot{ 502 | Name: val, 503 | }, 504 | }) 505 | } else { 506 | newBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 507 | } 508 | } 509 | 510 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketLogging, newlabels[1]) 511 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketLogging, newlabels[1], bucketPath)) 512 | } 513 | 514 | if versioning != nil { 515 | f.Body().AppendNewline() 516 | 517 | newlabels := []string{ResourceTypeAwsS3BucketVersioning.String(), fmt.Sprintf("%s_%s", labels[1], Versioning)} 518 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 519 | 520 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 521 | hcl.TraverseRoot{ 522 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 523 | }, 524 | }) 525 | 526 | versioningConfigBlock := newBlock.Body().AppendNewBlock("versioning_configuration", nil) 527 | 528 | for k, v := range versioning.Body().Attributes() { 529 | // Expected: enabled 530 | if k != "enabled" { 531 | continue 532 | } 533 | value := strings.TrimSpace(string(v.Expr().BuildTokens(nil).Bytes())) 534 | if value == "true" { 535 | expr := hclwrite.NewExpressionLiteral(cty.StringVal("Enabled")) 536 | versioningConfigBlock.Body().SetAttributeRaw("status", expr.BuildTokens(nil)) 537 | } else if value == "false" { 538 | // This might not be accurate as "false" can indicate never enable versioning 539 | expr := hclwrite.NewExpressionLiteral(cty.StringVal("Suspended")) 540 | versioningConfigBlock.Body().SetAttributeRaw("status", expr.BuildTokens(nil)) 541 | } 542 | } 543 | 544 | log.Printf(" ✓ Created %s.%s", newlabels[1], ResourceTypeAwsS3BucketVersioning) 545 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketVersioning, newlabels[1], bucketPath)) 546 | } 547 | 548 | if objectLockConfig != nil { 549 | f.Body().AppendNewline() 550 | 551 | newlabels := []string{ResourceTypeAwsS3BucketObjectLockConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], ObjectLockConfiguration)} 552 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 553 | 554 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 555 | hcl.TraverseRoot{ 556 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 557 | }, 558 | }) 559 | 560 | for k, v := range objectLockConfig.Body().Attributes() { 561 | // Expected: object_lock_enabled 562 | if k != "object_lock_enabled" { 563 | continue 564 | } 565 | newBlock.Body().SetAttributeRaw("object_lock_enabled", v.Expr().BuildTokens(nil)) 566 | } 567 | 568 | for _, ob := range objectLockConfig.Body().Blocks() { 569 | // we only expect 1 rule as defined in the aws_s3_bucket schema 570 | if ob.Type() != "rule" { 571 | continue 572 | } 573 | newBlock.Body().AppendBlock(ob) 574 | } 575 | 576 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketObjectLockConfiguration, newlabels[1]) 577 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketObjectLockConfiguration, newlabels[1], bucketPath)) 578 | } 579 | 580 | if replicationConfig != nil { 581 | f.Body().AppendNewline() 582 | 583 | newlabels := []string{ResourceTypeAwsS3BucketReplicationConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], ReplicationConfiguration)} 584 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 585 | 586 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 587 | hcl.TraverseRoot{ 588 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 589 | }, 590 | }) 591 | 592 | for k, v := range replicationConfig.Body().Attributes() { 593 | // Expected: role 594 | if k != "role" { 595 | continue 596 | } 597 | newBlock.Body().SetAttributeRaw("role", v.Expr().BuildTokens(nil)) 598 | } 599 | 600 | for _, b := range replicationConfig.Body().Blocks() { 601 | ruleBlock := newBlock.Body().AppendNewBlock("rule", nil) 602 | 603 | if b.Type() != "rules" { 604 | // not expected to hit this as the replication_configuration block only has the rules block 605 | continue 606 | } 607 | 608 | for k, v := range b.Body().Attributes() { 609 | // Expected: id, prefix, status, priority, delete_marker_replication_status 610 | switch k { 611 | case "id", "prefix", "status", "priority": 612 | ruleBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 613 | case "delete_marker_replication_status": 614 | // This is represented as a block in the new resource 615 | deleteMarkerBlock := ruleBlock.Body().AppendNewBlock("delete_marker_replication", nil) 616 | deleteMarkerBlock.Body().SetAttributeRaw("status", v.Expr().BuildTokens(nil)) 617 | } 618 | } 619 | 620 | for _, innerRuleBlock := range b.Body().Blocks() { 621 | // Expected: filter, source_selection_criteria, destination 622 | switch innerRuleBlock.Type() { 623 | case "destination": 624 | destBlock := ruleBlock.Body().AppendNewBlock("destination", nil) 625 | 626 | for k, v := range innerRuleBlock.Body().Attributes() { 627 | // Expected: account_id, bucket, storage_class, replica_kms_key_id 628 | switch k { 629 | case "account_id": 630 | // This is represented as "account" in the new resource 631 | destBlock.Body().SetAttributeRaw("account", v.Expr().BuildTokens(nil)) 632 | case "bucket", "storage_class": 633 | destBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 634 | case "replica_kms_key_id": 635 | // This is represented as an encryption_configuration block in the new resource 636 | encryptionBlock := destBlock.Body().AppendNewBlock("encryption_configuration", nil) 637 | encryptionBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 638 | } 639 | } 640 | 641 | for _, irb := range innerRuleBlock.Body().Blocks() { 642 | // Expected: access_control_translation, replication_time, metrics 643 | switch irb.Type() { 644 | case "access_control_translation": 645 | destBlock.Body().AppendBlock(irb) 646 | case "metrics": 647 | // This is represented as metrics.event_threshold.minutes and metrics.status in the new resource 648 | metricsBlock := destBlock.Body().AppendNewBlock("metrics", nil) 649 | for k, v := range irb.Body().Attributes() { 650 | // Expect: minutes, status 651 | switch k { 652 | case "minutes": 653 | // Need to wrap in a "event_threshold" block 654 | etBlock := metricsBlock.Body().AppendNewBlock("event_threshold", nil) 655 | etBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 656 | case "status": 657 | metricsBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 658 | } 659 | } 660 | case "replication_time": 661 | // This is represented as replication_time.time.minutes and replication_time.status in the new resource 662 | repTimeBlock := destBlock.Body().AppendNewBlock("replication_time", nil) 663 | for k, v := range irb.Body().Attributes() { 664 | // Expect: minutes, status 665 | switch k { 666 | case "minutes": 667 | // Need to wrap in a "time" block 668 | timeBlock := repTimeBlock.Body().AppendNewBlock("time", nil) 669 | timeBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 670 | case "status": 671 | repTimeBlock.Body().SetAttributeRaw(k, v.Expr().BuildTokens(nil)) 672 | } 673 | } 674 | } 675 | } 676 | 677 | case "filter": 678 | filterBlock := ruleBlock.Body().AppendNewBlock("filter", nil) 679 | 680 | m := make(map[string]*hclwrite.Attribute) 681 | 682 | for k, v := range innerRuleBlock.Body().Attributes() { 683 | // Expected: prefix and/or tags 684 | switch k { 685 | case "prefix", "tags": 686 | m[k] = v 687 | } 688 | } 689 | 690 | if vTags, ok := m["tags"]; ok { 691 | andBlock := filterBlock.Body().AppendNewBlock("and", nil) 692 | andBlock.Body().SetAttributeRaw("tags", vTags.Expr().BuildTokens(nil)) 693 | if vPrefix, vOk := m["prefix"]; vOk { 694 | andBlock.Body().SetAttributeRaw("prefix", vPrefix.Expr().BuildTokens(nil)) 695 | } else { 696 | andBlock.Body().SetAttributeValue("prefix", cty.StringVal("")) 697 | } 698 | } else if vPrefix, ok := m["prefix"]; ok { 699 | filterBlock.Body().SetAttributeRaw("prefix", vPrefix.Expr().BuildTokens(nil)) 700 | } 701 | case "source_selection_criteria": 702 | sscBlock := ruleBlock.Body().AppendNewBlock("source_selection_criteria", nil) 703 | 704 | for _, innerSscBlock := range innerRuleBlock.Body().Blocks() { 705 | switch innerSscBlock.Type() { 706 | case "sse_kms_encrypted_objects": 707 | sseBlock := sscBlock.Body().AppendNewBlock("sse_kms_encrypted_objects", nil) 708 | for k, v := range innerSscBlock.Body().Attributes() { 709 | if k != "enabled" { 710 | continue 711 | } 712 | 713 | value := strings.TrimSpace(string(v.Expr().BuildTokens(nil).Bytes())) 714 | 715 | if value == "true" { 716 | sseBlock.Body().SetAttributeValue("status", cty.StringVal("Enabled")) 717 | } else if value == "false" { 718 | sseBlock.Body().SetAttributeValue("status", cty.StringVal("Disabled")) 719 | } 720 | } 721 | } 722 | } 723 | } 724 | } 725 | } 726 | 727 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketReplicationConfiguration, newlabels[1]) 728 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketReplicationConfiguration, newlabels[1], bucketPath)) 729 | } 730 | 731 | if serverSideEncryptionConfig != nil { 732 | f.Body().AppendNewline() 733 | 734 | newlabels := []string{ResourceTypeAwsS3BucketServerSideEncryptionConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], ServerSideEncryptionConfiguration)} 735 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 736 | 737 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 738 | hcl.TraverseRoot{ 739 | Name: fmt.Sprintf("%s.%s.id", labels[0], labels[1]), 740 | }, 741 | }) 742 | 743 | for _, b := range serverSideEncryptionConfig.Body().Blocks() { 744 | // we only expect 1 rule as defined in the aws_s3_bucket schema 745 | if b.Type() != "rule" { 746 | continue 747 | } 748 | newBlock.Body().AppendBlock(b) 749 | } 750 | 751 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketServerSideEncryptionConfiguration, newlabels[1]) 752 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketServerSideEncryptionConfiguration, newlabels[1], bucketPath)) 753 | } 754 | 755 | if website != nil { 756 | f.Body().AppendNewline() 757 | 758 | newlabels := []string{ResourceTypeAwsS3BucketWebsiteConfiguration.String(), fmt.Sprintf("%s_%s", labels[1], WebsiteConfiguration)} 759 | newBlock := f.Body().AppendNewBlock(block.Type(), newlabels) 760 | 761 | // Account for dynamic blocks of this argument 762 | var hasForEach bool 763 | websiteForEachAttribute := website.Body().GetAttribute("for_each") 764 | if websiteForEachAttribute != nil { 765 | hasForEach = true 766 | newBlock.Body().SetAttributeRaw("for_each", websiteForEachAttribute.Expr().BuildTokens(nil)) 767 | newBlock.Body().AppendNewline() 768 | } 769 | 770 | bucketAttribute := fmt.Sprintf("%s.%s.id", labels[0], labels[1]) 771 | 772 | if (countAttr != nil || forEachAttr != nil) && hasForEach { 773 | bucketAttribute = fmt.Sprintf("%s.%s[each.key].id", labels[0], labels[1]) 774 | } 775 | 776 | newBlock.Body().SetAttributeTraversal("bucket", hcl.Traversal{ 777 | hcl.TraverseRoot{ 778 | Name: bucketAttribute, 779 | }, 780 | }) 781 | 782 | for k, v := range website.Body().Attributes() { 783 | switch k { 784 | case "index_document": 785 | indexDocBlock := newBlock.Body().AppendNewBlock("index_document", nil) 786 | 787 | if hasForEach { 788 | // Is it safe to assume this value will always be .value ? 789 | val := strings.Replace(string(v.Expr().BuildTokens(nil).Bytes()), "website.value", "each.value", 1) 790 | indexDocBlock.Body().SetAttributeTraversal("suffix", hcl.Traversal{ 791 | hcl.TraverseRoot{ 792 | Name: val, 793 | }, 794 | }) 795 | } else { 796 | indexDocBlock.Body().SetAttributeRaw("suffix", v.Expr().BuildTokens(nil)) 797 | } 798 | 799 | case "error_document": 800 | errDocBlock := newBlock.Body().AppendNewBlock("error_document", nil) 801 | 802 | if hasForEach { 803 | val := strings.Replace(string(v.Expr().BuildTokens(nil).Bytes()), "website.value", "each.value", 1) 804 | errDocBlock.Body().SetAttributeTraversal("key", hcl.Traversal{ 805 | hcl.TraverseRoot{ 806 | Name: val, 807 | }, 808 | }) 809 | } else { 810 | errDocBlock.Body().SetAttributeRaw("key", v.Expr().BuildTokens(nil)) 811 | } 812 | case "redirect_all_requests_to": 813 | redirectBlock := newBlock.Body().AppendNewBlock("redirect_all_requests_to", nil) 814 | 815 | if hasForEach { 816 | val := strings.Replace(string(v.Expr().BuildTokens(nil).Bytes()), "website.value", "each.value", 1) 817 | redirectBlock.Body().SetAttributeTraversal("host_name", hcl.Traversal{ 818 | hcl.TraverseRoot{ 819 | Name: val, 820 | }, 821 | }) 822 | } else { 823 | redirectBlock.Body().SetAttributeRaw("host_name", v.Expr().BuildTokens(nil)) 824 | } 825 | case "routing_rules": 826 | var unmarshalledRules []*s3.RoutingRule // if we can parse string as JSON 827 | var customUnmarshalledRules []*RoutingRule // if we can't parse string as JSON, try as YAML (e.g. when jsonencode func is used in terraform) 828 | 829 | routingRulesStr := strings.TrimSpace(string(v.Expr().BuildTokens(nil).Bytes())) 830 | indexOfOpenBracket := strings.Index(routingRulesStr, "[") 831 | indexOfCloseBracket := strings.LastIndex(routingRulesStr, "]") 832 | 833 | if indexOfOpenBracket == -1 || indexOfCloseBracket == -1 { 834 | log.Printf("[WARN] Unable to set 'routing_rule' in %s.%s.%s as configuration blocks from value", ResourceTypeAwsS3BucketWebsiteConfiguration, labels[1], WebsiteConfiguration) 835 | newBlock.Body().AppendUnstructuredTokens(hclwrite.Tokens{ 836 | { 837 | Type: hclsyntax.TokenComment, 838 | Bytes: []byte("# TODO: Replace with your 'routing_rule' configuration\n"), 839 | }, 840 | }) 841 | continue 842 | } 843 | 844 | routingRulesStr = routingRulesStr[indexOfOpenBracket : indexOfCloseBracket+1] 845 | 846 | if err := json.Unmarshal([]byte(routingRulesStr), &unmarshalledRules); err != nil { 847 | log.Printf("[DEBUG] Unable to json unmarshal 'routing_rule' in %s.%s_%s: %s. Trying yaml unmarshal...", ResourceTypeAwsS3BucketWebsiteConfiguration, labels[1], WebsiteConfiguration, err) 848 | if yamlErr := yaml.Unmarshal([]byte(routingRulesStr), &customUnmarshalledRules); yamlErr != nil { 849 | log.Printf("[DEBUG] Unable to yaml unmarshal 'routing_rule' in %s.%s_%s: %s", ResourceTypeAwsS3BucketWebsiteConfiguration, labels[1], WebsiteConfiguration, yamlErr) 850 | } 851 | } 852 | 853 | if len(unmarshalledRules) == 0 && len(customUnmarshalledRules) == 0 { 854 | log.Printf("[WARN] Unable to set 'routing_rule' in %s.%s_%s: no routing rules parsed", ResourceTypeAwsS3BucketWebsiteConfiguration, labels[1], WebsiteConfiguration) 855 | newBlock.Body().AppendUnstructuredTokens(hclwrite.Tokens{ 856 | { 857 | Type: hclsyntax.TokenComment, 858 | Bytes: []byte("# TODO: Replace with your 'routing_rule' configuration\n"), 859 | }, 860 | }) 861 | continue 862 | } 863 | 864 | for _, rule := range customUnmarshalledRules { 865 | routingRuleBlock := newBlock.Body().AppendNewBlock("routing_rule", nil) 866 | if c := rule.Condition; c != nil { 867 | conditionBlock := routingRuleBlock.Body().AppendNewBlock("condition", nil) 868 | if c.HttpErrorCodeReturnedEquals != nil { 869 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(c.HttpErrorCodeReturnedEquals))) 870 | conditionBlock.Body().SetAttributeRaw("http_error_code_returned_equals", expr.BuildTokens(nil)) 871 | } 872 | if c.KeyPrefixEquals != nil { 873 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(c.KeyPrefixEquals))) 874 | conditionBlock.Body().SetAttributeRaw("key_prefix_equals", expr.BuildTokens(nil)) 875 | } 876 | } 877 | 878 | if r := rule.Redirect; r != nil { 879 | redirectBlock := routingRuleBlock.Body().AppendNewBlock("redirect", nil) 880 | if r.HostName != nil { 881 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.HostName))) 882 | redirectBlock.Body().SetAttributeRaw("host_name", expr.BuildTokens(nil)) 883 | } 884 | if r.HttpRedirectCode != nil { 885 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.HttpRedirectCode))) 886 | redirectBlock.Body().SetAttributeRaw("http_redirect_code", expr.BuildTokens(nil)) 887 | } 888 | if r.Protocol != nil { 889 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.Protocol))) 890 | redirectBlock.Body().SetAttributeRaw("protocol", expr.BuildTokens(nil)) 891 | } 892 | if r.ReplaceKeyPrefixWith != nil { 893 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.ReplaceKeyPrefixWith))) 894 | redirectBlock.Body().SetAttributeRaw("replace_key_prefix_with", expr.BuildTokens(nil)) 895 | } 896 | if r.ReplaceKeyWith != nil { 897 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.ReplaceKeyWith))) 898 | redirectBlock.Body().SetAttributeRaw("replace_key_with", expr.BuildTokens(nil)) 899 | } 900 | } 901 | } 902 | 903 | for _, rule := range unmarshalledRules { 904 | routingRuleBlock := newBlock.Body().AppendNewBlock("routing_rule", nil) 905 | if c := rule.Condition; c != nil { 906 | conditionBlock := routingRuleBlock.Body().AppendNewBlock("condition", nil) 907 | if c.HttpErrorCodeReturnedEquals != nil { 908 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(c.HttpErrorCodeReturnedEquals))) 909 | conditionBlock.Body().SetAttributeRaw("http_error_code_returned_equals", expr.BuildTokens(nil)) 910 | } 911 | if c.KeyPrefixEquals != nil { 912 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(c.KeyPrefixEquals))) 913 | conditionBlock.Body().SetAttributeRaw("key_prefix_equals", expr.BuildTokens(nil)) 914 | } 915 | } 916 | 917 | if r := rule.Redirect; r != nil { 918 | redirectBlock := routingRuleBlock.Body().AppendNewBlock("redirect", nil) 919 | if r.HostName != nil { 920 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.HostName))) 921 | redirectBlock.Body().SetAttributeRaw("host_name", expr.BuildTokens(nil)) 922 | } 923 | if r.HttpRedirectCode != nil { 924 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.HttpRedirectCode))) 925 | redirectBlock.Body().SetAttributeRaw("http_redirect_code", expr.BuildTokens(nil)) 926 | } 927 | if r.Protocol != nil { 928 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.Protocol))) 929 | redirectBlock.Body().SetAttributeRaw("protocol", expr.BuildTokens(nil)) 930 | } 931 | if r.ReplaceKeyPrefixWith != nil { 932 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.ReplaceKeyPrefixWith))) 933 | redirectBlock.Body().SetAttributeRaw("replace_key_prefix_with", expr.BuildTokens(nil)) 934 | } 935 | if r.ReplaceKeyWith != nil { 936 | expr := hclwrite.NewExpressionLiteral(cty.StringVal(aws.StringValue(r.ReplaceKeyWith))) 937 | redirectBlock.Body().SetAttributeRaw("replace_key_with", expr.BuildTokens(nil)) 938 | } 939 | } 940 | } 941 | } 942 | } 943 | 944 | log.Printf(" ✓ Created %s.%s", ResourceTypeAwsS3BucketWebsiteConfiguration, newlabels[1]) 945 | m.newResourceNames = append(m.newResourceNames, fmt.Sprintf("%s.%s,%s", ResourceTypeAwsS3BucketWebsiteConfiguration, newlabels[1], bucketPath)) 946 | } 947 | } 948 | 949 | return nil 950 | } 951 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acceleration_status/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | acceleration_status = "Enabled" 4 | } -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acceleration_status/main_migrated.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | } 4 | resource "aws_s3_bucket_accelerate_configuration" "example_accelerate_configuration" { 5 | bucket = aws_s3_bucket.example.id 6 | status = "Enabled" 7 | } 8 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acceleration_status/main_new_resources.csv: -------------------------------------------------------------------------------- 1 | aws_s3_bucket_accelerate_configuration.example_accelerate_configuration,aws_s3_bucket.example 2 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acl/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | acl = "public-read" 4 | } -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acl/main_migrated.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | } 4 | resource "aws_s3_bucket_acl" "example_acl" { 5 | bucket = aws_s3_bucket.example.id 6 | acl = "public-read" 7 | } 8 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/acl/main_new_resources.csv: -------------------------------------------------------------------------------- 1 | aws_s3_bucket_acl.example_acl,aws_s3_bucket.example 2 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/cors_rule/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | 4 | cors_rule { 5 | allowed_headers = ["*"] 6 | allowed_methods = ["PUT", "POST"] 7 | allowed_origins = ["https://www.example.com"] 8 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 9 | max_age_seconds = 3000 10 | } 11 | 12 | cors_rule { 13 | allowed_headers = ["*"] 14 | allowed_methods = ["GET"] 15 | allowed_origins = [""] 16 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 17 | max_age_seconds = 3000 18 | } 19 | } -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/cors_rule/main_migrated.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = "my-example-bucket" 3 | 4 | 5 | } 6 | resource "aws_s3_bucket_cors_configuration" "example_cors_configuration" { 7 | bucket = aws_s3_bucket.example.id 8 | cors_rule { 9 | allowed_headers = ["*"] 10 | allowed_methods = ["PUT", "POST"] 11 | allowed_origins = ["https://www.example.com"] 12 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 13 | max_age_seconds = 3000 14 | } 15 | cors_rule { 16 | allowed_headers = ["*"] 17 | allowed_methods = ["GET"] 18 | allowed_origins = [""] 19 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 20 | max_age_seconds = 3000 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/cors_rule/main_new_resources.csv: -------------------------------------------------------------------------------- 1 | aws_s3_bucket_cors_configuration.example_cors_configuration,aws_s3_bucket.example 2 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/dynamic/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "a" { 2 | count = var.create_bucket ? 1 : 0 3 | 4 | bucket = var.bucket 5 | bucket_prefix = var.bucket_prefix 6 | 7 | dynamic "website" { 8 | for_each = length(keys(var.website)) == 0 ? [] : [var.website] 9 | 10 | content { 11 | index_document = lookup(website.value, "index_document", null) 12 | error_document = lookup(website.value, "error_document", null) 13 | redirect_all_requests_to = lookup(website.value, "redirect_all_requests_to", null) 14 | routing_rules = lookup(website.value, "routing_rules", null) 15 | } 16 | } 17 | } 18 | 19 | resource "aws_s3_bucket" "b" { 20 | count = var.create_bucket ? 1 : 0 21 | 22 | bucket = var.bucket 23 | bucket_prefix = var.bucket_prefix 24 | 25 | dynamic "logging" { 26 | for_each = length(keys(var.logging)) == 0 ? [] : [var.logging] 27 | 28 | content { 29 | target_bucket = logging.value.target_bucket 30 | target_prefix = lookup(logging.value, "target_prefix", null) 31 | } 32 | } 33 | } 34 | 35 | resource "aws_s3_bucket" "c" { 36 | count = var.create_bucket ? 1 : 0 37 | 38 | bucket = var.bucket 39 | bucket_prefix = var.bucket_prefix 40 | 41 | dynamic "cors_rule" { 42 | for_each = try(jsondecode(var.cors_rule), var.cors_rule) 43 | 44 | content { 45 | allowed_methods = cors_rule.value.allowed_methods 46 | allowed_origins = cors_rule.value.allowed_origins 47 | allowed_headers = lookup(cors_rule.value, "allowed_headers", null) 48 | expose_headers = lookup(cors_rule.value, "expose_headers", null) 49 | max_age_seconds = lookup(cors_rule.value, "max_age_seconds", null) 50 | } 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/dynamic/main_migrated.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "a" { 2 | count = var.create_bucket ? 1 : 0 3 | 4 | bucket = var.bucket 5 | bucket_prefix = var.bucket_prefix 6 | 7 | } 8 | 9 | resource "aws_s3_bucket" "b" { 10 | count = var.create_bucket ? 1 : 0 11 | 12 | bucket = var.bucket 13 | bucket_prefix = var.bucket_prefix 14 | 15 | } 16 | 17 | resource "aws_s3_bucket" "c" { 18 | count = var.create_bucket ? 1 : 0 19 | 20 | bucket = var.bucket 21 | bucket_prefix = var.bucket_prefix 22 | 23 | } 24 | 25 | 26 | resource "aws_s3_bucket_website_configuration" "a_website_configuration" { 27 | for_each = length(keys(var.website)) == 0 ? [] : [var.website] 28 | 29 | bucket = aws_s3_bucket.a[each.key].id 30 | error_document { 31 | key = lookup(each.value, "error_document", null) 32 | } 33 | redirect_all_requests_to { 34 | host_name = lookup(each.value, "redirect_all_requests_to", null) 35 | } 36 | # TODO: Replace with your 'routing_rule' configuration 37 | index_document { 38 | suffix = lookup(each.value, "index_document", null) 39 | } 40 | } 41 | 42 | resource "aws_s3_bucket_logging" "b_logging" { 43 | for_each = length(keys(var.logging)) == 0 ? [] : [var.logging] 44 | 45 | bucket = aws_s3_bucket.b[each.key].id 46 | target_bucket = each.value.target_bucket 47 | target_prefix = lookup(each.value, "target_prefix", null) 48 | } 49 | 50 | resource "aws_s3_bucket_cors_configuration" "c_cors_configuration" { 51 | # TODO: Replace with your intended 'for_each' value 52 | # for_each = try(jsondecode(var.cors_rule), var.cors_rule) 53 | 54 | # TODO: Replace 'bucket' argument value with correct instance index 55 | # e.g. aws_s3_bucket.c[count.index].id 56 | bucket = aws_s3_bucket.c.id 57 | dynamic "cors_rule" { 58 | for_each = try(jsondecode(var.cors_rule), var.cors_rule) 59 | 60 | content { 61 | allowed_methods = each.value.allowed_methods 62 | allowed_origins = each.value.allowed_origins 63 | allowed_headers = lookup(each.value, "allowed_headers", null) 64 | expose_headers = lookup(each.value, "expose_headers", null) 65 | max_age_seconds = lookup(each.value, "max_age_seconds", null) 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/dynamic/main_new_resources.csv: -------------------------------------------------------------------------------- 1 | aws_s3_bucket_website_configuration.a_website_configuration,aws_s3_bucket.a 2 | aws_s3_bucket_logging.b_logging,aws_s3_bucket.b 3 | aws_s3_bucket_cors_configuration.c_cors_configuration,aws_s3_bucket.c 4 | -------------------------------------------------------------------------------- /tfrefactor/tfrefactor/testdata/full/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | aws = { 4 | version = "3.74.0" 5 | } 6 | } 7 | } 8 | 9 | terraform { 10 | required_providers { 11 | aws = "3.74.0" 12 | } 13 | } 14 | 15 | provider "aws" { 16 | version = "3.74.0" 17 | } 18 | 19 | provider "random" {} 20 | 21 | variable "bucket_name" { 22 | default = "tf-acc-test-abc12345" 23 | type = string 24 | } 25 | 26 | data "aws_canonical_user_id" "current" {} 27 | 28 | data "aws_partition" "current" {} 29 | 30 | resource "random_pet" "example" {} 31 | 32 | resource "aws_s3_bucket" "b" { 33 | bucket = random_pet.example.id 34 | acl = "public-read" 35 | 36 | server_side_encryption_configuration { 37 | rule { 38 | apply_server_side_encryption_by_default { 39 | kms_master_key_id = aws_kms_key.arbitrary.arn 40 | sse_algorithm = "aws:kms" 41 | } 42 | } 43 | } 44 | } 45 | 46 | resource "aws_s3_bucket" "log_bucket" { 47 | bucket = "my-example-log-bucket-44444" 48 | acl = "private" 49 | 50 | server_side_encryption_configuration { 51 | rule { 52 | apply_server_side_encryption_by_default { 53 | sse_algorithm = "AES256" 54 | } 55 | } 56 | } 57 | } 58 | 59 | resource "aws_s3_bucket" "example" { 60 | bucket = var.bucket_name 61 | acceleration_status = "Enabled" 62 | 63 | cors_rule { 64 | allowed_headers = ["*"] 65 | allowed_methods = ["PUT", "POST"] 66 | allowed_origins = ["https://www.example.com"] 67 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 68 | max_age_seconds = 3000 69 | } 70 | 71 | cors_rule { 72 | allowed_headers = ["*"] 73 | allowed_methods = ["GET"] 74 | allowed_origins = [""] 75 | expose_headers = ["x-amz-server-side-encryption", "ETag"] 76 | max_age_seconds = 3000 77 | } 78 | 79 | grant { 80 | id = data.aws_canonical_user_id.current.id 81 | type = "CanonicalUser" 82 | permissions = ["WRITE", "FULL_CONTROL"] 83 | } 84 | 85 | grant { 86 | type = "Group" 87 | permissions = ["READ_ACP"] 88 | uri = "http://acs.amazonaws.com/groups/s3/LogDelivery" 89 | } 90 | 91 | lifecycle_rule { 92 | id = "id2" 93 | prefix = "path2/" 94 | enabled = true 95 | expiration { 96 | date = "2016-01-12" 97 | } 98 | } 99 | 100 | lifecycle_rule { 101 | id = "id5" 102 | enabled = true 103 | tags = { 104 | "tagKey" = "tagValue" 105 | "terraform" = "hashicorp" 106 | } 107 | transition { 108 | days = 0 109 | storage_class = "GLACIER" 110 | } 111 | } 112 | 113 | lifecycle_rule { 114 | id = "id6" 115 | enabled = true 116 | tags = { 117 | "tagKey" = "tagValue" 118 | } 119 | transition { 120 | days = 0 121 | storage_class = "GLACIER" 122 | } 123 | } 124 | 125 | lifecycle_rule { 126 | id = "id2" 127 | prefix = "path2/" 128 | enabled = false 129 | noncurrent_version_expiration { 130 | days = 365 131 | } 132 | } 133 | 134 | lifecycle_rule { 135 | id = "id3" 136 | prefix = "path3/" 137 | enabled = true 138 | noncurrent_version_transition { 139 | days = 0 140 | storage_class = "GLACIER" 141 | } 142 | } 143 | 144 | logging { 145 | target_bucket = aws_s3_bucket.log_bucket.id 146 | target_prefix = "log/" 147 | } 148 | 149 | object_lock_configuration { 150 | object_lock_enabled = "Enabled" 151 | 152 | rule { 153 | default_retention { 154 | mode = "COMPLIANCE" 155 | days = 3 156 | } 157 | } 158 | } 159 | 160 | policy = <