AWSTemplateFormatVersion: 2010-09-09
Description: This stack creates an SQS Queue which subscribes to marketplace SNS notifications.

Parameters:
  ClazarRoleName:
    Description: Clazar Role Name
    Type: String
  ClazarSqsQueueName:
    Description: SQS Queue Name
    Type: String

Mappings:
  SQS:
    ClazarSqsAccessPolicyName:
      Value: ClazarSQSAccess

Resources:
  ClazarSqsQueue:
    Type: 'AWS::SQS::Queue'
    Properties:
      QueueName: !Ref ClazarSqsQueueName

  ClazarSQSAccessPolicy:
    DependsOn:
      - ClazarSqsQueue
    Type: AWS::IAM::Policy
    Properties:
      PolicyName: !FindInMap [SQS, ClazarSqsAccessPolicyName, Value]
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Action:
              - 'sqs:*'
            Resource: !GetAtt ClazarSqsQueue.Arn
      Roles:
        - !Ref ClazarRoleName

Outputs:
  ClazarSqsQueueName:
    Description: The name of the queue
    Value: !GetAtt ClazarSqsQueue.QueueName
  ClazarSqsQueueArn:
    Description: The ARN of the queue
    Value: !GetAtt ClazarSqsQueue.Arn
  ClazarSqsQueueUrl:
    Description: The URL of the queue
    Value: !GetAtt ClazarSqsQueue.QueueUrl
