Catalog of golang-based CloudFormation CustomResources
-
Create a new struct that embeds
CustomResourceCommand
- This struct MUST embedGoAWSCustomResource
as in:type HelloWorldResource struct { GoAWSCustomResource Message string }
-
Ensure the new type implements
CustomResourceCommand
by adding: -create(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error)
-update(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error)
-delete(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error)
-
Add a package level var denoting the resource type - The value MUST be generated by
cloudFormationResourceType(...)
to include the proper custom resource prefix. Example:HelloWorld = cloudFormationResourceType("HelloWorldResource")
-
Add a
case
label incustomCommandForTypeName
for the custom resource type added in step 2.
- This block is responsible for creating a new command instance and unmarshalling the properties into the type-specific values. - Assign the new command to the customCommand interface. Example:case HelloWorld: command := HelloWorldResource{ GoAWSCustomResource: GoAWSCustomResource{ GoAWSType: resourceTypeName, }, } if nil != properties { unmarshalError = json.Unmarshal([]byte(string(*properties)), &command) } customCommand = &command }