Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check on import name split length #2067

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
4 changes: 2 additions & 2 deletions products/accesscontextmanager/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_flatten: templates/terraform/custom_flatten/default_if_empty.erb
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/access_level_never_send_parent.go.erb
custom_import: templates/terraform/custom_import/access_level_self_link_as_name_and_set_parent.go.erb
custom_import: templates/terraform/custom_import/set_access_policy_parent_from_self_link.go.erb
ServicePerimeter: !ruby/object:Overrides::Terraform::ResourceOverride
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 6
Expand All @@ -79,7 +79,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
input: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/access_level_never_send_parent.go.erb
custom_import: templates/terraform/custom_import/access_level_self_link_as_name_and_set_parent.go.erb
custom_import: templates/terraform/custom_import/set_access_policy_parent_from_self_link.go.erb
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
return nil, err
}
stringParts := strings.Split(d.Get("name").(string), "/")
if len(stringParts) < 2 {
return nil, fmt.Errorf("Error parsing parent name. Should be in form accessPolicies/{{policy_id}}/<%= object.name.pluralize.camelize(:lower) -%>/{{short_name}}")
}
d.Set("parent", fmt.Sprintf("%s/%s", stringParts[0], stringParts[1]))
return []*schema.ResourceData{d}, nil