Documentation
¶
Overview ¶
Package cloudhsmv2 emulates the AWS CloudHSM v2 control plane: clusters, HSMs and backups.
Index ¶
- Variables
- type Backup
- type Cluster
- type CreateClusterInput
- type DeleteHsmInput
- type DescribeBackupsInput
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type Hsm
- type InMemoryBackend
- func (b *InMemoryBackend) CopyBackupToRegion(ctx context.Context, id, destRegion string, tagList []wireTag) (wireDestinationBackup, error)
- func (b *InMemoryBackend) CreateCluster(ctx context.Context, in CreateClusterInput) (wireCluster, error)
- func (b *InMemoryBackend) CreateHsm(ctx context.Context, clusterID, zone, ip string) (wireHsm, error)
- func (b *InMemoryBackend) DeleteBackup(ctx context.Context, id string) (wireBackup, error)
- func (b *InMemoryBackend) DeleteCluster(ctx context.Context, id string) (wireCluster, error)
- func (b *InMemoryBackend) DeleteHsm(ctx context.Context, in DeleteHsmInput) (string, error)
- func (b *InMemoryBackend) DeleteResourcePolicy(ctx context.Context, resourceARN string) (string, error)
- func (b *InMemoryBackend) DescribeBackups(ctx context.Context, in DescribeBackupsInput) (page.Page[wireBackup], error)
- func (b *InMemoryBackend) DescribeClusters(ctx context.Context, filters map[string][]string, token string, ...) (page.Page[wireCluster], error)
- func (b *InMemoryBackend) GetResourcePolicy(ctx context.Context, resourceARN string) (string, error)
- func (b *InMemoryBackend) InitializeCluster(ctx context.Context, id, signedCert, trustAnchor string) (string, string, error)
- func (b *InMemoryBackend) ListTags(ctx context.Context, ref, token string, maxResults *int32) (page.Page[wireTag], error)
- func (b *InMemoryBackend) ModifyBackupAttributes(ctx context.Context, id string, neverExpires bool) (wireBackup, error)
- func (b *InMemoryBackend) ModifyCluster(ctx context.Context, in ModifyClusterInput) (wireCluster, error)
- func (b *InMemoryBackend) PutResourcePolicy(ctx context.Context, resourceARN, policy string) (string, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RestoreBackup(ctx context.Context, id string) (wireBackup, error)
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) SetNetwork(n Network)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(ctx context.Context, ref string, tagList []wireTag) error
- func (b *InMemoryBackend) UntagResource(ctx context.Context, ref string, keys []string) error
- type ModifyClusterInput
- type Network
- type Provider
- type Subnet
Constants ¶
This section is empty.
Variables ¶
var ( ErrAccessDenied = errors.New("access denied") ErrInternalFailure = errors.New("internal failure") ErrInvalidRequest = errors.New("invalid request") ErrResourceLimitExceeded = errors.New("resource limit exceeded") ErrResourceNotFound = errors.New("resource not found") ErrService = errors.New("service error") ErrTag = errors.New("invalid tag") )
Sentinels, one per exception in the pinned SDK's error set.
Functions ¶
This section is empty.
Types ¶
type Backup ¶
type Backup struct {
Created time.Time `json:"created"`
ReadyAt time.Time `json:"readyAt"`
CopyTime time.Time `json:"copyTime"`
DeleteAt time.Time `json:"deleteAt"`
Tags map[string]string `json:"tags"`
ID string `json:"id"`
Account string `json:"account"`
Region string `json:"region"`
ClusterID string `json:"clusterId"`
HsmType string `json:"hsmType"`
Mode string `json:"mode"`
ClusterCert string `json:"clusterCert,omitempty"`
SourceBackup string `json:"sourceBackup,omitempty"`
SourceCluster string `json:"sourceCluster,omitempty"`
SourceRegion string `json:"sourceRegion,omitempty"`
Policy string `json:"policy,omitempty"`
RetentionDays int `json:"retentionDays"`
NeverExpires bool `json:"neverExpires"`
}
Backup is a stored cluster backup.
type Cluster ¶
type Cluster struct {
Created time.Time `json:"created"`
ReadyAt time.Time `json:"readyAt"`
InitUntil time.Time `json:"initUntil"`
ModifyUntil time.Time `json:"modifyUntil"`
RollbackExpiry time.Time `json:"rollbackExpiry"`
DeletedAt time.Time `json:"deletedAt"`
DeleteUntil time.Time `json:"deleteUntil"`
SubnetMapping map[string]string `json:"subnetMapping"`
Tags map[string]string `json:"tags"`
ID string `json:"id"`
Account string `json:"account"`
Region string `json:"region"`
HsmType string `json:"hsmType"`
Mode string `json:"mode"`
NetworkType string `json:"networkType"`
VpcID string `json:"vpcId"`
SecurityGroup string `json:"securityGroup"`
SourceBackupID string `json:"sourceBackupId,omitempty"`
CSR string `json:"csr"`
ClusterCert string `json:"clusterCert,omitempty"`
RetentionDays int `json:"retentionDays"`
Initialized bool `json:"initialized"`
}
Cluster is a stored CloudHSM cluster.
type CreateClusterInput ¶
type CreateClusterInput struct {
Retention *wireRetention
HsmType string
Mode string
NetworkType string
SourceBackupID string
SubnetIDs []string
Tags []wireTag
}
CreateClusterInput holds CreateCluster parameters.
type DeleteHsmInput ¶
type DeleteHsmInput struct {
ClusterID, HsmID, EniID, EniIP string
}
DeleteHsmInput identifies the HSM to delete by one of its ID, ENI ID or ENI IP.
type DescribeBackupsInput ¶
type DescribeBackupsInput struct {
Filters map[string][]string
MaxResults *int32
NextToken string
SortAscending bool
}
DescribeBackupsInput holds DescribeBackups parameters.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
}
Handler serves the CloudHSM v2 awsjson1.1 API.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions this handler serves.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name from X-Amz-Target.
func (*Handler) ExtractResource ¶
ExtractResource returns the operation name; the API has no single resource key.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every routed operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches the BaldrApiService X-Amz-Target prefix.
type Hsm ¶
type Hsm struct {
Created time.Time `json:"created"`
ReadyAt time.Time `json:"readyAt"`
DeletedAt time.Time `json:"deletedAt"`
DeleteUntil time.Time `json:"deleteUntil"`
ID string `json:"id"`
ClusterID string `json:"clusterId"`
Account string `json:"account"`
Region string `json:"region"`
Zone string `json:"zone"`
SubnetID string `json:"subnetId"`
EniID string `json:"eniId"`
EniIP string `json:"eniIp"`
HsmType string `json:"hsmType"`
}
Hsm is a stored HSM.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the CloudHSM v2 state; one coarse lock guards every table.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) CopyBackupToRegion ¶
func (b *InMemoryBackend) CopyBackupToRegion( ctx context.Context, id, destRegion string, tagList []wireTag, ) (wireDestinationBackup, error)
CopyBackupToRegion copies a ready backup into another region.
func (*InMemoryBackend) CreateCluster ¶
func (b *InMemoryBackend) CreateCluster(ctx context.Context, in CreateClusterInput) (wireCluster, error)
CreateCluster creates a cluster, optionally restored from a backup.
func (*InMemoryBackend) CreateHsm ¶
func (b *InMemoryBackend) CreateHsm(ctx context.Context, clusterID, zone, ip string) (wireHsm, error)
CreateHsm adds an HSM to a cluster in the given Availability Zone.
func (*InMemoryBackend) DeleteBackup ¶
func (b *InMemoryBackend) DeleteBackup(ctx context.Context, id string) (wireBackup, error)
DeleteBackup schedules a backup for deletion; it can be restored for seven days.
func (*InMemoryBackend) DeleteCluster ¶
func (b *InMemoryBackend) DeleteCluster(ctx context.Context, id string) (wireCluster, error)
DeleteCluster starts deleting a cluster that has no HSMs.
func (*InMemoryBackend) DeleteHsm ¶
func (b *InMemoryBackend) DeleteHsm(ctx context.Context, in DeleteHsmInput) (string, error)
DeleteHsm starts deleting an HSM and returns its ID.
func (*InMemoryBackend) DeleteResourcePolicy ¶
func (b *InMemoryBackend) DeleteResourcePolicy(ctx context.Context, resourceARN string) (string, error)
DeleteResourcePolicy removes and returns the policy attached to a backup.
func (*InMemoryBackend) DescribeBackups ¶
func (b *InMemoryBackend) DescribeBackups(ctx context.Context, in DescribeBackupsInput) (page.Page[wireBackup], error)
DescribeBackups lists the caller's backups, or those shared with it.
func (*InMemoryBackend) DescribeClusters ¶
func (b *InMemoryBackend) DescribeClusters( ctx context.Context, filters map[string][]string, token string, maxResults *int32, ) (page.Page[wireCluster], error)
DescribeClusters lists the caller's clusters.
func (*InMemoryBackend) GetResourcePolicy ¶
func (b *InMemoryBackend) GetResourcePolicy(ctx context.Context, resourceARN string) (string, error)
GetResourcePolicy returns the policy attached to a backup.
func (*InMemoryBackend) InitializeCluster ¶
func (b *InMemoryBackend) InitializeCluster( ctx context.Context, id, signedCert, trustAnchor string, ) (string, string, error)
InitializeCluster claims a cluster with a signed certificate and trust anchor.
func (*InMemoryBackend) ListTags ¶
func (b *InMemoryBackend) ListTags( ctx context.Context, ref, token string, maxResults *int32, ) (page.Page[wireTag], error)
ListTags pages the tags of a cluster or backup.
func (*InMemoryBackend) ModifyBackupAttributes ¶
func (b *InMemoryBackend) ModifyBackupAttributes( ctx context.Context, id string, neverExpires bool, ) (wireBackup, error)
ModifyBackupAttributes exempts a backup from, or returns it to, the cluster retention policy.
func (*InMemoryBackend) ModifyCluster ¶
func (b *InMemoryBackend) ModifyCluster(ctx context.Context, in ModifyClusterInput) (wireCluster, error)
ModifyCluster changes the backup retention policy and/or HSM type.
func (*InMemoryBackend) PutResourcePolicy ¶
func (b *InMemoryBackend) PutResourcePolicy(ctx context.Context, resourceARN, policy string) (string, error)
PutResourcePolicy attaches a policy to a READY backup the caller owns.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the default region.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version is discarded.
func (*InMemoryBackend) RestoreBackup ¶
func (b *InMemoryBackend) RestoreBackup(ctx context.Context, id string) (wireBackup, error)
RestoreBackup cancels a pending backup deletion.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay overrides how long clusters, HSMs and backups stay in a transitional state.
func (*InMemoryBackend) SetNetwork ¶
func (b *InMemoryBackend) SetNetwork(n Network)
SetNetwork wires the EC2 lookups used for subnets, security groups and ENIs.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(ctx context.Context, ref string, tagList []wireTag) error
TagResource adds or replaces tags on a cluster or backup.
func (*InMemoryBackend) UntagResource ¶
UntagResource removes tags by key.
type ModifyClusterInput ¶
ModifyClusterInput holds ModifyCluster parameters.
type Network ¶
type Network interface {
// SubnetInfo returns the VPC and Availability Zone of each requested subnet that exists in the region.
SubnetInfo(region string, subnetIDs []string) map[string]Subnet
CreateSecurityGroup(region, name, description, vpcID string) (string, error)
DeleteSecurityGroup(region, id string)
CreateENI(region, subnetID, ip, securityGroupID, description string) (eniID, eniIP string, err error)
DeleteENI(region, id string)
}
Network is the VPC surface the backend needs: subnet lookup, security group and ENI management.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS CloudHSM v2.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.