Skip to content

Commit

Permalink
Add check on import name split length (#2067)
Browse files Browse the repository at this point in the history
Merged PR #2067.
  • Loading branch information
slevenick authored and modular-magician committed Jul 17, 2019
1 parent 3c113ff commit 1c21795
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
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

0 comments on commit 1c21795

Please sign in to comment.