|
| 1 | +service: stac-server |
| 2 | + |
| 3 | +provider: |
| 4 | + name: aws |
| 5 | + runtime: nodejs16.x |
| 6 | + stage: ${opt:stage, 'dev'} |
| 7 | + region: ${opt:region, 'us-west-2'} |
| 8 | + # uncomment this if using a bucket that already exists for deployment files |
| 9 | + # deploymentBucket: |
| 10 | + # name: my-deployment-bucket |
| 11 | + environment: |
| 12 | + STAC_ID: "stac-server" |
| 13 | + STAC_TITLE: "STAC API" |
| 14 | + STAC_DESCRIPTION: "A STAC API using stac-server" |
| 15 | + LOG_LEVEL: debug |
| 16 | + STAC_DOCS_URL: https://stac-utils.github.io/stac-server/ |
| 17 | + OPENSEARCH_HOST: |
| 18 | + Fn::GetAtt: [OpenSearchInstance, DomainEndpoint] |
| 19 | + ENABLE_TRANSACTIONS_EXTENSION: false |
| 20 | + # comment STAC_API_ROOTPATH if deployed with a custom domain |
| 21 | + STAC_API_ROOTPATH: "/${self:provider.stage}" |
| 22 | + # PRE_HOOK: ${self:service}-${self:provider.stage}-preHook |
| 23 | + # PRE_HOOK_AUTH_TOKEN: xxx |
| 24 | + # PRE_HOOK_AUTH_TOKEN_TXN: xxx |
| 25 | + # POST_HOOK: ${self:service}-${self:provider.stage}-postHook |
| 26 | + iam: |
| 27 | + role: |
| 28 | + statements: |
| 29 | + - Effect: "Allow" |
| 30 | + Resource: "arn:aws:es:${aws:region}:${aws:accountId}:domain/*" |
| 31 | + Action: "es:*" |
| 32 | + - Effect: "Allow" |
| 33 | + Action: |
| 34 | + - sqs:GetQueueUrl |
| 35 | + - sqs:SendMessage |
| 36 | + - sqs:ReceiveMessage |
| 37 | + - sqs:DeleteMessage |
| 38 | + Resource: |
| 39 | + Fn::GetAtt: [ingestQueue, Arn] |
| 40 | + - Effect: Allow |
| 41 | + Action: s3:GetObject |
| 42 | + Resource: 'arn:aws:s3:::usgs-landsat/*' |
| 43 | + # - Effect: "Allow" |
| 44 | + # Action: "lambda:InvokeFunction" |
| 45 | + # Resource: "arn:aws:lambda:${aws:region}:${aws:accountId}:function:${self:service}-${self:provider.stage}-preHook" |
| 46 | + # - Effect: "Allow" |
| 47 | + # Action: "lambda:InvokeFunction" |
| 48 | + # Resource: "arn:aws:lambda:${aws:region}:${aws:accountId}:function:${self:service}-${self:provider.stage}-postHook" |
| 49 | + |
| 50 | +package: |
| 51 | + individually: true |
| 52 | + |
| 53 | +functions: |
| 54 | + api: |
| 55 | + description: stac-server API Lambda |
| 56 | + handler: index.handler |
| 57 | + package: |
| 58 | + artifact: dist/api/api.zip |
| 59 | + events: |
| 60 | + - http: |
| 61 | + method: ANY |
| 62 | + path: "/" |
| 63 | + cors: true |
| 64 | + - http: |
| 65 | + method: ANY |
| 66 | + path: "{proxy+}" |
| 67 | + cors: true |
| 68 | + ingest: |
| 69 | + description: stac-server Ingest Lambda |
| 70 | + handler: index.handler |
| 71 | + memorySize: 512 |
| 72 | + timeout: 60 |
| 73 | + package: |
| 74 | + artifact: dist/ingest/ingest.zip |
| 75 | + events: |
| 76 | + - sqs: |
| 77 | + arn: |
| 78 | + Fn::GetAtt: [ingestQueue, Arn] |
| 79 | + # preHook: |
| 80 | + # description: stac-server pre-hook Lambda |
| 81 | + # handler: index.handler |
| 82 | + # memorySize: 512 |
| 83 | + # timeout: 25 |
| 84 | + # package: |
| 85 | + # artifact: dist/pre-hook/pre-hook.zip |
| 86 | + |
| 87 | + # postHook: |
| 88 | + # description: stac-server post-hook Lambda |
| 89 | + # handler: index.handler |
| 90 | + # memorySize: 512 |
| 91 | + # timeout: 25 |
| 92 | + # package: |
| 93 | + # artifact: dist/post-hook/post-hook.zip |
| 94 | + |
| 95 | +resources: |
| 96 | + Description: A STAC API running on stac-server |
| 97 | + Resources: |
| 98 | + ingestTopic: |
| 99 | + Type: "AWS::SNS::Topic" |
| 100 | + Properties: |
| 101 | + TopicName: ${self:service}-${self:provider.stage}-ingest |
| 102 | + deadLetterQueue: |
| 103 | + Type: AWS::SQS::Queue |
| 104 | + Properties: |
| 105 | + QueueName: ${self:service}-${self:provider.stage}-dead-letter-queue |
| 106 | + ingestQueue: |
| 107 | + Type: AWS::SQS::Queue |
| 108 | + Properties: |
| 109 | + VisibilityTimeout: 120 |
| 110 | + ReceiveMessageWaitTimeSeconds: 5 |
| 111 | + QueueName: ${self:service}-${self:provider.stage}-queue |
| 112 | + RedrivePolicy: |
| 113 | + deadLetterTargetArn: !GetAtt deadLetterQueue.Arn |
| 114 | + maxReceiveCount: 2 |
| 115 | + ingestQueuePolicy: |
| 116 | + Type: AWS::SQS::QueuePolicy |
| 117 | + Properties: |
| 118 | + Queues: |
| 119 | + - !Ref ingestQueue |
| 120 | + PolicyDocument: |
| 121 | + Statement: |
| 122 | + - Sid: allow-sqs-sendmessage |
| 123 | + Effect: Allow |
| 124 | + Principal: |
| 125 | + AWS: "*" |
| 126 | + Action: SQS:SendMessage |
| 127 | + Resource: !GetAtt ingestQueue.Arn |
| 128 | + Condition: |
| 129 | + ArnEquals: |
| 130 | + aws:SourceArn: !Ref ingestTopic |
| 131 | + ingestSubscription: |
| 132 | + Type: AWS::SNS::Subscription |
| 133 | + Properties: |
| 134 | + Endpoint: !GetAtt ingestQueue.Arn |
| 135 | + Protocol: sqs |
| 136 | + Region: "${aws:region}" |
| 137 | + TopicArn: !Ref ingestTopic |
| 138 | + OpenSearchInstance: |
| 139 | + Type: AWS::OpenSearchService::Domain |
| 140 | + DeletionPolicy : Retain |
| 141 | + UpdateReplacePolicy: Retain |
| 142 | + UpdatePolicy: |
| 143 | + EnableVersionUpgrade: true |
| 144 | + Properties: |
| 145 | + DomainName: ${self:service}-${self:provider.stage} |
| 146 | + EBSOptions: |
| 147 | + EBSEnabled: true |
| 148 | + VolumeType: gp3 |
| 149 | + VolumeSize: 35 |
| 150 | + ClusterConfig: |
| 151 | + InstanceType: t3.small.search |
| 152 | + InstanceCount: 1 |
| 153 | + DedicatedMasterEnabled: false |
| 154 | + ZoneAwarenessEnabled: false |
| 155 | + EngineVersion: OpenSearch_2.3 |
| 156 | + DomainEndpointOptions: |
| 157 | + EnforceHTTPS: true |
| 158 | + Outputs: |
| 159 | + OpenSearchEndpoint: |
| 160 | + Value: |
| 161 | + Fn::GetAtt: [OpenSearchInstance, DomainEndpoint] |
| 162 | + Export: |
| 163 | + Name: ${self:service}-${self:provider.stage}-os-endpoint |
| 164 | + |
| 165 | +plugins: |
| 166 | + - serverless-offline |
0 commit comments