{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Disposable architecture exercise foundation: state, work delivery and private output. Application adapters are implemented separately.",
  "Resources": {
    "StateTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "BillingMode": "PAY_PER_REQUEST",
        "AttributeDefinitions": [
          {
            "AttributeName": "pk",
            "AttributeType": "S"
          },
          {
            "AttributeName": "sk",
            "AttributeType": "S"
          }
        ],
        "KeySchema": [
          {
            "AttributeName": "pk",
            "KeyType": "HASH"
          },
          {
            "AttributeName": "sk",
            "KeyType": "RANGE"
          }
        ],
        "PointInTimeRecoverySpecification": {
          "PointInTimeRecoveryEnabled": true
        },
        "TimeToLiveSpecification": {
          "AttributeName": "expires_at",
          "Enabled": true
        }
      }
    },
    "DeadLetterQueue": {
      "Type": "AWS::SQS::Queue",
      "Properties": {
        "MessageRetentionPeriod": 1209600,
        "SqsManagedSseEnabled": true
      }
    },
    "WorkQueue": {
      "Type": "AWS::SQS::Queue",
      "Properties": {
        "VisibilityTimeout": 60,
        "MessageRetentionPeriod": 345600,
        "ReceiveMessageWaitTimeSeconds": 20,
        "SqsManagedSseEnabled": true,
        "RedrivePolicy": {
          "deadLetterTargetArn": {
            "Fn::GetAtt": [
              "DeadLetterQueue",
              "Arn"
            ]
          },
          "maxReceiveCount": 5
        }
      }
    },
    "OutputBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "PublicAccessBlockConfiguration": {
          "BlockPublicAcls": true,
          "BlockPublicPolicy": true,
          "IgnorePublicAcls": true,
          "RestrictPublicBuckets": true
        },
        "BucketEncryption": {
          "ServerSideEncryptionConfiguration": [
            {
              "ServerSideEncryptionByDefault": {
                "SSEAlgorithm": "AES256"
              }
            }
          ]
        },
        "LifecycleConfiguration": {
          "Rules": [
            {
              "Id": "AbandonedMultipartUploads",
              "Status": "Enabled",
              "AbortIncompleteMultipartUpload": {
                "DaysAfterInitiation": 7
              },
              "Prefix": ""
            }
          ]
        }
      }
    }
  },
  "Outputs": {
    "StateTableName": {
      "Value": {
        "Ref": "StateTable"
      }
    },
    "StateTableArn": {
      "Value": {
        "Fn::GetAtt": [
          "StateTable",
          "Arn"
        ]
      }
    },
    "WorkQueueUrl": {
      "Value": {
        "Ref": "WorkQueue"
      }
    },
    "WorkQueueArn": {
      "Value": {
        "Fn::GetAtt": [
          "WorkQueue",
          "Arn"
        ]
      }
    },
    "DeadLetterQueueUrl": {
      "Value": {
        "Ref": "DeadLetterQueue"
      }
    },
    "OutputBucketName": {
      "Value": {
        "Ref": "OutputBucket"
      }
    },
    "OutputBucketArn": {
      "Value": {
        "Fn::GetAtt": [
          "OutputBucket",
          "Arn"
        ]
      }
    }
  }
}
