-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add terraform import script #130
Conversation
Any go logging library recommendations? The logging works, but want to improve the look of the logs |
on: | ||
push: | ||
tags: | ||
- 'import-v*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont forget to test this after merge
import/import_script.go
Outdated
}(resource) | ||
} | ||
|
||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why we need a goroutine here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the block above parallelizes the import block generation step for each resource in individual go routines
to ensure that all the go routines are finished, we need a separate goroutine to wait for all the goroutines to finish writing to the channel before closing the channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it work the same without the goroutine?
to me, it seems like without go routine makes more sense so just
wg.Wait()
close(results)
but maybe im missing something
return nil | ||
} | ||
|
||
func generateDeploymentHCL(ctx context.Context, platformClient *platform.ClientWithResponses, organizationId string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats HCL mean here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashiCorp Configuration Language
"golang.org/x/exp/maps" | ||
) | ||
|
||
func HandleWorkspaces(ctx context.Context, platformClient *mocksPlatform.ClientWithResponsesInterface, iamClient *mocksIam.ClientWithResponsesInterface, organizationId string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can all these functions just go in the test file instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i wanted to separate it so its cleaner but i can move them all in there too
Description
Add an import script that will enable users to migrate all of their resources to be managed by terraform. The script will read from existing resources (by listing all orgs, deployments, clusters, etc) and then correctly import them into terraform.
How the script works:
import.tf
terraform plan -generate-config-out=generated.tf
, writing all Terraform resource configs to a file,generated.tf
terraform apply
on the new resources, successfully importing all resources!Example
import.tf
file:Example
generated.tf
file:🎟 Issue(s)
#115
Migration Doc
🧪 Functional Testing
Workspace
Cluster
Hybrid Cluster Workspace Authorization
No hybrid clusters to test with
Deployment
Team
Team Roles
API Token
User Roles
Importing Multiple Resources
📸 Screenshots
📋 Checklist
examples/
directory