Documentation
¶
Overview ¶
Package resources defines a set of CloudFormation Custom Resources that are implemented by Lambda functions. These resources are serialized to JSON and are instantiated by Sparta when an application requests a CustomAction handler. They must implement CustomResourceCommand to be properly invoked.
Index ¶
- Constants
- Variables
- func CloudFormationLambdaCustomResourceHandler(command CustomResourceCommand, logger *zerolog.Logger) interface{}
- func NewCustomResourceLambdaHandler(resourceType string, logger *zerolog.Logger) interface{}
- func SendCloudFormationResponse(lambdaCtx *awsLambdaCtx.LambdaContext, event *CloudFormationLambdaEvent, ...) error
- func ToCustomResourceProperties(crr interface{}) map[string]interface{}
- type CloudFormationLambdaEvent
- type CloudWatchEventSourceResourceRequest
- type CloudWatchLogsLambdaEventSourceFilter
- type CloudWatchLogsLambdaEventSourceResource
- func (command CloudWatchLogsLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command CloudWatchLogsLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *CloudWatchLogsLambdaEventSourceResource) IAMPrivileges() []string
- func (command CloudWatchLogsLambdaEventSourceResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type CodeCommitLambdaEventSourceResource
- func (command CodeCommitLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command CodeCommitLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *CodeCommitLambdaEventSourceResource) IAMPrivileges() []string
- func (command CodeCommitLambdaEventSourceResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type CodeCommitLambdaEventSourceResourceRequest
- type CustomResourceCommand
- type CustomResourcePrivilegedCommand
- type CustomResourceRequest
- type HelloWorldResource
- func (command HelloWorldResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command HelloWorldResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *HelloWorldResource) IAMPrivileges() []string
- func (command HelloWorldResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type HelloWorldResourceRequest
- type S3ArtifactPublisherResource
- func (command S3ArtifactPublisherResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command S3ArtifactPublisherResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *S3ArtifactPublisherResource) IAMPrivileges() []string
- func (command S3ArtifactPublisherResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type S3ArtifactPublisherResourceRequest
- type S3LambdaEventSourceResource
- func (command S3LambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command S3LambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *S3LambdaEventSourceResource) IAMPrivileges() []string
- func (command S3LambdaEventSourceResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type S3LambdaEventSourceResourceRequest
- type SESLambdaEventSourceResource
- func (command SESLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command SESLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *SESLambdaEventSourceResource) IAMPrivileges() []string
- func (command SESLambdaEventSourceResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type SESLambdaEventSourceResourceAction
- type SESLambdaEventSourceResourceRequest
- type SESLambdaEventSourceResourceRule
- type SNSLambdaEventSourceResource
- func (command SNSLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command SNSLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *SNSLambdaEventSourceResource) IAMPrivileges() []string
- func (command SNSLambdaEventSourceResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type SNSLambdaEventSourceResourceRequest
- type ZipToS3BucketResource
- func (command ZipToS3BucketResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command ZipToS3BucketResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- func (command *ZipToS3BucketResource) IAMPrivileges() []string
- func (command ZipToS3BucketResource) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, ...) (map[string]interface{}, error)
- type ZipToS3BucketResourceRequest
Constants ¶
const ( // CreateOperation is a request to create a resource // @enum CloudFormationOperation CreateOperation = "Create" // DeleteOperation is a request to delete a resource // @enum CloudFormationOperation DeleteOperation = "Delete" // UpdateOperation is a request to update a resource // @enum CloudFormationOperation UpdateOperation = "Update" )
const ( // CustomResourceTypePrefix is the known custom resource // type prefix CustomResourceTypePrefix = "Custom::Sparta" )
const DefaultManifestName = "MANIFEST.json"
DefaultManifestName is the name of the file that will be created at the root of the S3 bucket with user-supplied metadata
Variables ¶
var ( // HelloWorld is the typename for HelloWorldResource HelloWorld = cloudFormationCustomResourceType("HelloWorldResource") // S3LambdaEventSource is the typename for S3LambdaEventSourceResource S3LambdaEventSource = cloudFormationCustomResourceType("S3EventSource") // SNSLambdaEventSource is the typename for SNSLambdaEventSourceResource SNSLambdaEventSource = cloudFormationCustomResourceType("SNSEventSource") // CodeCommitLambdaEventSource is the type name for CodeCommitEventSourceResource CodeCommitLambdaEventSource = cloudFormationCustomResourceType("CodeCommitEventSource") // SESLambdaEventSource is the typename for SESLambdaEventSourceResource SESLambdaEventSource = cloudFormationCustomResourceType("SESEventSource") // CloudWatchLogsLambdaEventSource is the typename for SESLambdaEventSourceResource CloudWatchLogsLambdaEventSource = cloudFormationCustomResourceType("CloudWatchLogsEventSource") // ZipToS3Bucket is the typename for ZipToS3Bucket ZipToS3Bucket = cloudFormationCustomResourceType("ZipToS3Bucket") // S3ArtifactPublisher is the typename for publishing an S3Artifact S3ArtifactPublisher = cloudFormationCustomResourceType("S3ArtifactPublisher") )
Functions ¶
func CloudFormationLambdaCustomResourceHandler ¶
func CloudFormationLambdaCustomResourceHandler(command CustomResourceCommand, logger *zerolog.Logger) interface{}
CloudFormationLambdaCustomResourceHandler is an adapter function that transforms an implementing CustomResourceCommand into something that that can respond to the lambda custom resource lifecycle
func NewCustomResourceLambdaHandler ¶
NewCustomResourceLambdaHandler returns a handler for the given type
func SendCloudFormationResponse ¶
func SendCloudFormationResponse(lambdaCtx *awsLambdaCtx.LambdaContext, event *CloudFormationLambdaEvent, results map[string]interface{}, responseErr error, logger *zerolog.Logger) error
SendCloudFormationResponse sends the given response to the CloudFormation URL that was submitted together with this event
func ToCustomResourceProperties ¶
func ToCustomResourceProperties(crr interface{}) map[string]interface{}
Types ¶
type CloudFormationLambdaEvent ¶
type CloudFormationLambdaEvent struct { RequestType string RequestID string `json:"RequestId"` ResponseURL string ResourceType string StackID string `json:"StackId"` LogicalResourceID string `json:"LogicalResourceId"` ResourceProperties json.RawMessage OldResourceProperties json.RawMessage }
CloudFormationLambdaEvent is the event to a resource
type CloudWatchEventSourceResourceRequest ¶
type CloudWatchEventSourceResourceRequest struct { CustomResourceRequest LambdaTargetArn string Filters []*CloudWatchLogsLambdaEventSourceFilter RoleARN string `json:",omitempty"` }
CloudWatchEventSourceResourceRequest is what the UserProperties should be set to in the CustomResource invocation
type CloudWatchLogsLambdaEventSourceFilter ¶
type CloudWatchLogsLambdaEventSourceFilter struct { Name string Pattern string LogGroupName string }
CloudWatchLogsLambdaEventSourceFilter represents a filter for a cloudwatchlogs stream
type CloudWatchLogsLambdaEventSourceResource ¶
type CloudWatchLogsLambdaEventSourceResource struct {
gof.CustomResource
}
CloudWatchLogsLambdaEventSourceResource is a simple POC showing how to create custom resources
func (CloudWatchLogsLambdaEventSourceResource) Create ¶
func (command CloudWatchLogsLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the create operation
func (CloudWatchLogsLambdaEventSourceResource) Delete ¶
func (command CloudWatchLogsLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the delete operation
func (*CloudWatchLogsLambdaEventSourceResource) IAMPrivileges ¶
func (command *CloudWatchLogsLambdaEventSourceResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type CodeCommitLambdaEventSourceResource ¶
type CodeCommitLambdaEventSourceResource struct {
gof.CustomResource
}
CodeCommitLambdaEventSourceResource is a simple POC showing how to create custom resources
func (CodeCommitLambdaEventSourceResource) Create ¶
func (command CodeCommitLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the custom resource create operation
func (CodeCommitLambdaEventSourceResource) Delete ¶
func (command CodeCommitLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the custom resource delete operation
func (*CodeCommitLambdaEventSourceResource) IAMPrivileges ¶
func (command *CodeCommitLambdaEventSourceResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type CodeCommitLambdaEventSourceResourceRequest ¶
type CodeCommitLambdaEventSourceResourceRequest struct { CustomResourceRequest LambdaTargetArn string RepositoryName string TriggerName string Events []string `json:",omitempty"` Branches []string `json:",omitempty"` }
CodeCommitLambdaEventSourceResourceRequest defines the request properties to configure SNS
type CustomResourceCommand ¶
type CustomResourceCommand interface { Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error) Update(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error) }
CustomResourceCommand defines operations that a CustomResource must implement.
type CustomResourcePrivilegedCommand ¶
type CustomResourcePrivilegedCommand interface { // The IAMPrivileges this command requires of the IAM role IAMPrivileges() []string }
CustomResourcePrivilegedCommand is a command that also has IAM privileges which implies there must be an ARN associated with the command
type CustomResourceRequest ¶
type CustomResourceRequest struct {
ServiceToken string
}
CustomResourceRequest is the default type for all requests that support ServiceToken
type HelloWorldResource ¶
type HelloWorldResource struct {
gof.CustomResource
}
HelloWorldResource is a simple POC showing how to create custom resources
func (HelloWorldResource) Create ¶
func (command HelloWorldResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements resource create
func (HelloWorldResource) Delete ¶
func (command HelloWorldResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements resource delete
func (*HelloWorldResource) IAMPrivileges ¶
func (command *HelloWorldResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type HelloWorldResourceRequest ¶
type HelloWorldResourceRequest struct { CustomResourceRequest Message string }
HelloWorldResourceRequest is what the UserProperties should be set to in the CustomResource invocation
type S3ArtifactPublisherResource ¶
type S3ArtifactPublisherResource struct {
gof.CustomResource
}
S3ArtifactPublisherResource is a simple POC showing how to create custom resources
func (S3ArtifactPublisherResource) Create ¶
func (command S3ArtifactPublisherResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the S3 create operation
func (S3ArtifactPublisherResource) Delete ¶
func (command S3ArtifactPublisherResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the S3 delete operation
func (*S3ArtifactPublisherResource) IAMPrivileges ¶
func (command *S3ArtifactPublisherResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type S3ArtifactPublisherResourceRequest ¶
type S3ArtifactPublisherResourceRequest struct { CustomResourceRequest Bucket string Key string Body map[string]interface{} }
S3ArtifactPublisherResourceRequest is what the UserProperties should be set to in the CustomResource invocation
type S3LambdaEventSourceResource ¶
type S3LambdaEventSourceResource struct {
gof.CustomResource
}
S3LambdaEventSourceResource manages registering a Lambda function with S3 event
func (S3LambdaEventSourceResource) Create ¶
func (command S3LambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the custom resource create operation
func (S3LambdaEventSourceResource) Delete ¶
func (command S3LambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the custom resource delete operation
func (*S3LambdaEventSourceResource) IAMPrivileges ¶
func (command *S3LambdaEventSourceResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type S3LambdaEventSourceResourceRequest ¶
type S3LambdaEventSourceResourceRequest struct { CustomResourceRequest BucketArn string Events []string LambdaTargetArn string Filter *awsv2S3Types.NotificationConfigurationFilter `json:"Filter,omitempty"` }
S3LambdaEventSourceResourceRequest is what the UserProperties should be set to in the CustomResource invocation
type SESLambdaEventSourceResource ¶
type SESLambdaEventSourceResource struct {
gof.CustomResource
}
SESLambdaEventSourceResource handles configuring SES configuration
func (SESLambdaEventSourceResource) Create ¶
func (command SESLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the custom resource create operation
func (SESLambdaEventSourceResource) Delete ¶
func (command SESLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the custom resource delete operation
func (*SESLambdaEventSourceResource) IAMPrivileges ¶
func (command *SESLambdaEventSourceResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type SESLambdaEventSourceResourceAction ¶
type SESLambdaEventSourceResourceAction struct { ActionType string ActionProperties map[string]interface{} }
SESLambdaEventSourceResourceAction represents an SES rule action TODO - specialized types for Actions
type SESLambdaEventSourceResourceRequest ¶
type SESLambdaEventSourceResourceRequest struct { CustomResourceRequest RuleSetName string Rules []*SESLambdaEventSourceResourceRule }
SESLambdaEventSourceResourceRequest defines the request properties to configure SES
type SESLambdaEventSourceResourceRule ¶
type SESLambdaEventSourceResourceRule struct { Name string Actions []*SESLambdaEventSourceResourceAction ScanEnabled string `json:",omitempty"` Enabled string `json:",omitempty"` Recipients []string TLSPolicy string `json:",omitempty"` }
SESLambdaEventSourceResourceRule stores settings necessary to configure an SES inbound rule. Boolean types are strings to workaround https://forums.aws.amazon.com/thread.jspa?threadID=302268
type SNSLambdaEventSourceResource ¶
type SNSLambdaEventSourceResource struct {
gof.CustomResource
}
SNSLambdaEventSourceResource is a simple POC showing how to create custom resources
func (SNSLambdaEventSourceResource) Create ¶
func (command SNSLambdaEventSourceResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the custom resource create operation
func (SNSLambdaEventSourceResource) Delete ¶
func (command SNSLambdaEventSourceResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the custom resource delete operation
func (*SNSLambdaEventSourceResource) IAMPrivileges ¶
func (command *SNSLambdaEventSourceResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type SNSLambdaEventSourceResourceRequest ¶
type SNSLambdaEventSourceResourceRequest struct { CustomResourceRequest LambdaTargetArn string SNSTopicArn string }
SNSLambdaEventSourceResourceRequest defines the request properties to configure SNS
type ZipToS3BucketResource ¶
type ZipToS3BucketResource struct {
gof.CustomResource
}
ZipToS3BucketResource manages populating an S3 bucket with the contents of a ZIP file...
func (ZipToS3BucketResource) Create ¶
func (command ZipToS3BucketResource) Create(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Create implements the custom resource create operation
func (ZipToS3BucketResource) Delete ¶
func (command ZipToS3BucketResource) Delete(ctx context.Context, awsConfig awsv2.Config, event *CloudFormationLambdaEvent, logger *zerolog.Logger) (map[string]interface{}, error)
Delete implements the custom resource delete operation
func (*ZipToS3BucketResource) IAMPrivileges ¶
func (command *ZipToS3BucketResource) IAMPrivileges() []string
IAMPrivileges returns the IAM privs for this custom action
type ZipToS3BucketResourceRequest ¶
type ZipToS3BucketResourceRequest struct { CustomResourceRequest SrcBucket string SrcKeyName string DestBucket string ManifestName string Manifest map[string]interface{} }
ZipToS3BucketResourceRequest is the data request made to a ZipToS3BucketResource lambda handler