{"id":18284502,"url":"https://github.com/pplu/sqs-worker-cfn","last_synced_at":"2025-04-09T05:46:47.869Z","repository":{"id":66753308,"uuid":"133423701","full_name":"pplu/sqs-worker-cfn","owner":"pplu","description":"A helper to develop your own custom CloudFormation resources","archived":false,"fork":false,"pushed_at":"2019-04-29T22:55:47.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T00:25:52.669Z","etag":null,"topics":["cloudformation","custom","custom-resources","resource","sns"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pplu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-14T21:29:14.000Z","updated_at":"2019-04-29T22:55:48.000Z","dependencies_parsed_at":"2023-02-24T16:15:13.893Z","dependency_job_id":null,"html_url":"https://github.com/pplu/sqs-worker-cfn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fsqs-worker-cfn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fsqs-worker-cfn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fsqs-worker-cfn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pplu%2Fsqs-worker-cfn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pplu","download_url":"https://codeload.github.com/pplu/sqs-worker-cfn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987107,"owners_count":21028891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudformation","custom","custom-resources","resource","sns"],"created_at":"2024-11-05T13:13:45.637Z","updated_at":"2025-04-09T05:46:47.848Z","avatar_url":"https://github.com/pplu.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nSQS::Worker::CloudFormationResource - A helper to develop your own custom CloudFormation resources\n\n# DESCRIPTION\n\nThis is a [SQS::Worker](https://metacpan.org/pod/SQS::Worker) role that helps you develop SNS-based CloudFormation Custom Resources that deliver to an\nSQS queue.\n\nMore information on SNS based Custom Resources here: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-sns.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-sns.html)\n\nThis module takes care of lots of repetitive work when building an SNS-based CloudFormation Custom Resource.\n\n# USAGE\n\n    package MyCustomResource {\n      use Moose;\n      with 'SQS::Worker', 'SQS::Worker::SNS', 'SQS::Worker::CloudFormationResource';\n\n      sub create_resource {\n        my ($self, $request, $result) = @_;\n        # $request is a SQS::Worker::CloudFormationResource::Request\n        # $result  is a SQS::Worker::CloudFormationResource::Response\n      }\n\n      sub update_resource {\n        my ($self, $request, $result) = @_;\n      }\n\n      sub delete_resource {\n        my ($self, $request, $result) = @_;\n      }\n    }\n\n# WRITING A CUSTOM RESOURCE\n\nThe worker will poll the SQS queue for you, invoking `create_resource`, `update_resource`\nor `delete_resource` in function of what is happening in CloudFormation, passing them a \nrequest object with all the information coming from CloudFormation. Look at [SQS::Worker::CloudFormationResource::Request](https://metacpan.org/pod/SQS::Worker::CloudFormationResource::Request)\nfor more information on what information a request has. result is an object that has [SQS::Worker::CloudFormationResource::Response](https://metacpan.org/pod/SQS::Worker::CloudFormationResource::Response).\nSet the appropiate properties of the response object. The response object will be returned to CloudFormation.\n\n    $result-\u003eset_success('Created resource'); # the success message will show in the cloudformation log\n    $result-\u003ePhysicalResourceId('resource-123456');\n    $result-\u003eData({\n      Color =\u003e 'Blue',\n    });\n\nWhen calling update\\_resource: `PhysicalResourceId` will already be initialized to the PhisicalResourceId that was set in `create_resource`,\nmeaning that if it isn't updated, CloudFormation considers the update as a in-place replacement. If a new `PhysicalResourceId` is assigned,\nCloudFormation considers the operation as a replacement. Later on, CloudFormation will send a Delete for the old PhysicalResourceId, which\nshouldn't be handled as any special case: the `delete_resource` will be invoked.\n\nUnhandled exceptions in any `resource_*` methods will be handled, returning a generic \"Internal Error\" text to CloudFormation,\nconsidering the resource FAILED.\n\nUnhandled exceptions in `resource_create` will treat the resource creation as a special case. Since CloudFormation requires a Physical ID to\nbe sent, even if we're signalling a FAILURE, SQS::Worker::CloudFormationResource will use an internal Physical ID, that will never be delivered\nto the `delete_resource` method (it will be intercepted and dropped before getting processed).\n\n# SETTING UP A CUSTOM RESOURCE\n\nTo use the resource in CloudFormation, you have to provision an SNS topic that delivers it's messages\nto an SQS queue. You can setup an SNS topic with the bundled `examples/sns-topic-for-cloudformation.json` file (which will output\nall the data you need to run the worker\n\n    spawn_worker --worker CustomResourceExample1 --queue_url=http://..../QueueURL --region=eu-west-1 --log_conf log.conf\n\n# USING YOUR CUSTOM RESOURCE\n\n    { \"resources\": [\n      \"Custom1\": {\n        \"Type\": \"Custom::MyCustomResource\",\n        \"Version\": \"1.0\",\n        \"Properties\": {\n          \"ServiceToken\": \"arn:of the SNS topic for the custom resource\",\n          ... Resource Properties ...\n        }\n      }\n    ] }\n\nThe data you have set in the `Data` property of the response object will be accessible in CloudFormation templates via the GetAtt\nfunction.\n\n    { \"Fn::GetAtt\": [ \"Custom1\", \"Color\" ] }\n\n# METHODS\n\n## create\\_resource($request, $response)\n\nImplement this method in your Custom Resource worker class. All properties sent by CloudFormation will be in `$request` of type \n[SQS::Worker::CloudFormationResource::Request](https://metacpan.org/pod/SQS::Worker::CloudFormationResource::Request). This method should modify `$response` to control what will be sent to CloudFormation.\nThe following can be done:\n\nEither call `set_success` or `set_failed`\n\nSet attribute `PhysicalResourceId` (`$response-\u0026gt;('resource-123456');`)\n\nSet attribute `Data` to a Hashref with the keys and values that CloudFormation will treat as this objects attributes\n\n## update\\_resource\n\nImplement this method in your Custom Resource worker class.\n\n## delete\\_resource\n\nImplement this method in your Custom Resource worker class.\n\nEither call `set_success` or `set_failed` to indicate that the resource was deleted or not\n\n# SEE ALSO\n\n[SQS::Worker](https://metacpan.org/pod/SQS::Worker)\n\n[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-sns.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-sns.html)\n\n[Paws::SQS](https://metacpan.org/pod/Paws::SQS)\n\n# COPYRIGHT and LICENSE\n\nCopyright (c) 2018 by CAPSiDE\n\nThis code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module.\n\n# AUTHORS\n\n    Jose Luis Martinez\n    JLMARTIN\n    jlmartinez@capside.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpplu%2Fsqs-worker-cfn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpplu%2Fsqs-worker-cfn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpplu%2Fsqs-worker-cfn/lists"}