-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
113 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package serviceaccount | ||
|
||
const ( | ||
resourceName = "cyral_service_account" | ||
|
||
// Schema keys | ||
ServiceAccountResourceDisplayNameKey = "display_name" | ||
ServiceAccountResourcePermissionIDsKey = "permission_ids" | ||
ServiceAccountResourceClientIDKey = "client_id" | ||
ServiceAccountResourceClientSecretKey = "client_secret" | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package serviceaccount | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cyralinc/terraform-provider-cyral/cyral/client" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/utils" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var resourceContextHandler = core.DefaultContextHandler{ | ||
ResourceName: resourceName, | ||
ResourceType: resourcetype.Resource, | ||
SchemaReaderFactory: func() core.SchemaReader { return &ServiceAccount{} }, | ||
SchemaWriterFactoryGetMethod: func(_ *schema.ResourceData) core.SchemaWriter { return &ServiceAccount{} }, | ||
BaseURLFactory: func(d *schema.ResourceData, c *client.Client) string { | ||
return fmt.Sprintf("https://%s/v1/users/serviceAccounts", c.ControlPlane) | ||
}, | ||
} | ||
|
||
func resourceSchema() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Manages a Cyral Service Account (A.k.a: " + | ||
"[Cyral API Access Key](https://cyral.com/docs/api-ref/api-intro/#api-access-key)). See also " + | ||
"data source [`cyral_permission`](../data-sources/permission.md)." + | ||
"\n\n-> **Note** This resource does not support importing, since the client secret cannot " + | ||
"be read after the resource creation.", | ||
CreateContext: resourceContextHandler.CreateContext(), | ||
ReadContext: resourceContextHandler.ReadContext(), | ||
UpdateContext: resourceContextHandler.UpdateContext(), | ||
DeleteContext: resourceContextHandler.DeleteContext(), | ||
|
||
Schema: map[string]*schema.Schema{ | ||
ServiceAccountResourceDisplayNameKey: { | ||
Description: "The service account display name.", | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
ServiceAccountResourcePermissionIDsKey: { | ||
Description: "A list of permission IDs that will be assigned to this service account. See " + | ||
"also data source [`cyral_permission`](../data-sources/permission.md).", | ||
Type: schema.TypeSet, | ||
Required: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
utils.IDKey: { | ||
Description: fmt.Sprintf( | ||
"The resource identifier. It's equal to `%s`.", | ||
ServiceAccountResourceClientIDKey, | ||
), | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
ServiceAccountResourceClientIDKey: { | ||
Description: "The service account client ID.", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
ServiceAccountResourceClientSecretKey: { | ||
Description: "The service account client secret. **Note**: This resource is not able to recognize " + | ||
"changes to the client secret after its creation, so keep in mind that if the client secret is " + | ||
"rotated, the value present in this attribute will be outdated. If you need to rotate the client " + | ||
"secret it's recommended that you recreate this terraform resource.", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
}, | ||
}, | ||
} | ||
} |
134 changes: 0 additions & 134 deletions
134
cyral/internal/serviceaccount/resource_cyral_service_account.go
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package serviceaccount | ||
|
||
import ( | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
) | ||
|
||
type packageSchema struct { | ||
} | ||
|
||
func (p *packageSchema) Name() string { | ||
return "serviceaccount" | ||
} | ||
|
||
func (p *packageSchema) Schemas() []*core.SchemaDescriptor { | ||
return []*core.SchemaDescriptor{ | ||
{ | ||
Name: resourceName, | ||
Type: core.ResourceSchemaType, | ||
Schema: resourceSchema, | ||
}, | ||
} | ||
} | ||
|
||
func PackageSchema() core.PackageSchema { | ||
return &packageSchema{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters