Skip to content

mweagle/cloudformationresources

 
 

Repository files navigation

CloudFormationResources

Catalog of golang-based CloudFormation CustomResources

Adding a New Resource

  1. Create a new struct that embeds CustomResourceCommand - This struct MUST embed GoAWSCustomResource as in: type HelloWorldResource struct { GoAWSCustomResource Message string }

  2. 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)

  3. 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")
    
  4. Add a case label in customCommandForTypeName 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
      }
    

About

Catalog of golang-based CloudFormation CustomResources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%