Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Adding Support for SNS Subscriptions
Browse files Browse the repository at this point in the history
**Why:**

* Allows you to take a SNS topic and subscribe to any standrad protocol
  with custom hoosk for SQS

**This change addresses the need by:**

* closes #36

Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Sep 5, 2018
1 parent 1bfa2b8 commit 030a0cb
Show file tree
Hide file tree
Showing 23 changed files with 525 additions and 90 deletions.
2 changes: 1 addition & 1 deletion cloudformation/ecrrepository.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Service Broker - Amazon SNS (qs-1nt0fs93c)'
Description: 'AWS Operator - Amazon ECR Repository'
Parameters:
Namespace:
Description: >-
Expand Down
72 changes: 72 additions & 0 deletions cloudformation/snssubscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Operator - Amazon SNS Subscription'
Parameters:
Namespace:
Description: >-
This is the namespace for the Kubernetes object.
Type: String
ResourceVersion:
Type: String
Description: >-
This is the resource version for the Kubernetes object.
ResourceName:
Description: >-
This is the resource name for the Kubernetes object
Type: String
ClusterName:
Description: >-
This is the cluster name for the operator
Type: String
TopicARN:
Type: String
Description: >-
What is the Amazon SNS Topic ARN to subscribe to?
Protocol:
Type: String
Description: >-
What is the protocol for the endpoint?
Endpoint:
Type: String
Description: >-
What is the endpoint address?
QueueURL:
Type: String
Description: >-
What is the SQS Queue URL?
Conditions:
UseSQS: !Equals [!Ref Protocol, "sqs"]

Resources:
SNSSubscription:
Type: 'AWS::SNS::Subscription'
Properties:
Endpoint: !Ref Endpoint
Protocol: !Ref Protocol
TopicArn: !Ref TopicARN
Region: !Ref "AWS::Region"

SQSQueuePolicy:
Type: 'AWS::SQS::QueuePolicy'
Condition: UseSQS
Properties:
PolicyDocument:
Id: AWSOperatorQueuePolicy
Version: '2012-10-17'
Statement:
- Sid: AllowSendReceive
Effect: Allow
Principal: "*"
Action:
- SQS:SendMessage
Resource: !Ref Endpoint
Condition:
ArnEquals:
"aws:SourceArn": !Ref TopicARN
Queues:
- !Ref QueueURL

Outputs:
SubscriptionARN:
Value: !Ref SNSSubscription
Description: Subscription ARN
8 changes: 2 additions & 6 deletions cloudformation/snstopic.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Service Broker - Amazon SNS (qs-1nt0fs93c)'
Description: 'AWS Operator - Amazon SNS Topic'
Parameters:
Namespace:
Description: >-
Expand All @@ -17,15 +17,11 @@ Parameters:
Description: >-
This is the cluster name for the operator
Type: String
DisplayName:
Type: String
Description: >-
What should the SNS Topics name display as.
Resources:
SNSTopic:
Type: 'AWS::SNS::Topic'

Outputs:
TopicName:
TopicARN:
Value: !Ref SNSTopic
Description: Name of the topic
2 changes: 1 addition & 1 deletion cloudformation/sqsqueue.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AWSTemplateFormatVersion: 2010-09-09
Description: "AWS Servicebroker - Amazon SQS (qs-1nt0fs93h)"
Description: "AWS Operator - Amazon SQS Queue"
Parameters:
Namespace:
Type: String
Expand Down
1 change: 1 addition & 0 deletions examples/cloudformationtemplates/dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ data:
TableArn:
Description: Arn of the DynamoDB Table
Value: !GetAtt DynamoDBTable.Arn
43 changes: 43 additions & 0 deletions examples/cloudformationtemplates/ecrrepository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: operator.aws/v1alpha1
kind: CloudFormationTemplate
metadata:
name: ecrrepository
data:
key: ecrrepository.yaml
template: |
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Operator - Amazon ECR Repository'
Parameters:
Namespace:
Description: >-
This is the namespace for the Kubernetes object.
Type: String
ResourceVersion:
Type: String
Description: >-
This is the resource version for the Kubernetes object.
ResourceName:
Description: >-
This is the resource name for the Kubernetes object
Type: String
ClusterName:
Description: >-
This is the cluster name for the operator
Type: String
RepositoryName:
Type: String
Description: >-
What should the ECR Repository be named
Resources:
ECRRepository:
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Ref RepositoryName
Outputs:
RepositoryName:
Value: !Ref ECRRepository
Description: Name of the topic
RepositoryARN:
Value: !GetAtt ECRRepository.Arn
Description: ARN of the Repository
79 changes: 79 additions & 0 deletions examples/cloudformationtemplates/snssubscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: operator.aws/v1alpha1
kind: CloudFormationTemplate
metadata:
name: snssubscription
data:
key: snssubscription.yaml
template: |
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Operator - Amazon SNS Subscription'
Parameters:
Namespace:
Description: >-
This is the namespace for the Kubernetes object.
Type: String
ResourceVersion:
Type: String
Description: >-
This is the resource version for the Kubernetes object.
ResourceName:
Description: >-
This is the resource name for the Kubernetes object
Type: String
ClusterName:
Description: >-
This is the cluster name for the operator
Type: String
TopicARN:
Type: String
Description: >-
What is the Amazon SNS Topic ARN to subscribe to?
Protocol:
Type: String
Description: >-
What is the protocol for the endpoint?
Endpoint:
Type: String
Description: >-
What is the endpoint address?
QueueURL:
Type: String
Description: >-
What is the SQS Queue URL?
Conditions:
UseSQS: !Equals [!Ref Protocol, "sqs"]
Resources:
SNSSubscription:
Type: 'AWS::SNS::Subscription'
Properties:
Endpoint: !Ref Endpoint
Protocol: !Ref Protocol
TopicArn: !Ref TopicARN
Region: !Ref "AWS::Region"
SQSQueuePolicy:
Type: 'AWS::SQS::QueuePolicy'
Condition: UseSQS
Properties:
PolicyDocument:
Id: AWSOperatorQueuePolicy
Version: '2012-10-17'
Statement:
- Sid: AllowSendReceive
Effect: Allow
Principal: "*"
Action:
- SQS:SendMessage
Resource: !Ref Endpoint
Condition:
ArnEquals:
"aws:SourceArn": !Ref TopicARN
Queues:
- !Ref QueueURL
Outputs:
SubscriptionARN:
Value: !Ref SNSSubscription
Description: Subscription ARN
34 changes: 34 additions & 0 deletions examples/cloudformationtemplates/snstopic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: operator.aws/v1alpha1
kind: CloudFormationTemplate
metadata:
name: snstopic
data:
key: snstopic.yaml
template: |
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Operator - Amazon SNS Topic'
Parameters:
Namespace:
Description: >-
This is the namespace for the Kubernetes object.
Type: String
ResourceVersion:
Type: String
Description: >-
This is the resource version for the Kubernetes object.
ResourceName:
Description: >-
This is the resource name for the Kubernetes object
Type: String
ClusterName:
Description: >-
This is the cluster name for the operator
Type: String
Resources:
SNSTopic:
Type: 'AWS::SNS::Topic'
Outputs:
TopicARN:
Value: !Ref SNSTopic
Description: Name of the topic
Loading

0 comments on commit 030a0cb

Please sign in to comment.