'AWS SAM Serverless App publish failing (missing meta data, but template has it populated)
Hoping someone can see my, likely obviously mistake here...
Trying to publish to new basic app to the AWS SAR.
Using aws-serverless-twitter-event-source ([enter link description here][1]) example, trying to package a new version (i've copied to my own private repo) as a starting point, and putting into (private) AWS Serverless Application Repository. However when-ever I publish it fails complaining of missing Application Meta data but its definitely in there (see file at the bottom)
Successful build/deploy steps:
$ sam package --output-template-file packaged.yaml --s3-bucket blahbucket
$ sam deploy --template-file /Users/ben/repos/aws-serverless-twitter-event-source/packaged.yaml --stack-name astes1 --parameter-overrides TweetProcessorFunctionName=blah SearchText='covid' --capabilities CAPABILITY_IAM
$ sam publish --template packaged.yaml --region us-east-2
Publish Failed
Error: Application metadata not found in the SAM template: 'missing AWS::ServerlessRepo::Application section in template Metadata'
I've tried various things
- ensuring spaces not tabs
- start/end of file
- various orders
Anyone any ideas on my layout/format issues? or is this a mis-leading error message....? . Really hope so as tearing my hair out!
template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
SearchText:
Type: String
Default: 'covid'
Description: Non-URL-encoded search text poller should use when querying Twitter Search API.
TweetProcessorFunctionName:
Type: String
Default: 'blahfunction'
Description: Name of lambda function that should be invoked to process tweets. Note, this must be a function name and not a function ARN.
SSMParameterPrefix:
Type: String
Default: 'twitter-event-source'
Description: >
This app assumes API keys needed to use the Twitter API are stored as SecureStrings in SSM Parameter Store under the prefix defined by
this parameter. See the app README for details.
PollingFrequencyInMinutes:
Type: Number
MinValue: 1
Default: 1
Description: Frequency in minutes to poll for more tweets.
BatchSize:
Type: Number
MinValue: 1
Default: 15
Description: Max number of tweets to send to the TweetProcessor lambda function on each invocation.
StreamModeEnabled:
Type: String
Default: false
AllowedValues:
- true
- false
Description: If true, the app will remember the last tweet found and only invoke the tweet processor function for newer tweets. If false, the app will be stateless and invoke the tweet processor function with all tweets found in each polling cycle.
Conditions:
IsPollingFrequencyInMinutesSingular: !Equals [!Ref PollingFrequencyInMinutes, 1]
Resources:
TwitterSearchPoller:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Runtime: python3.8
Handler: poller.handler
Tracing: Active
MemorySize: 128
Timeout: 60
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref TweetProcessorFunctionName
- DynamoDBCrudPolicy:
TableName: !Ref SearchCheckpoint
- Statement:
Effect: Allow
Action:
- ssm:GetParameters
Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${SSMParameterPrefix}/*
Environment:
Variables:
SSM_PARAMETER_PREFIX: !Ref SSMParameterPrefix
SEARCH_TEXT: !Ref SearchText
SEARCH_CHECKPOINT_TABLE_NAME: !Ref SearchCheckpoint
TWEET_PROCESSOR_FUNCTION_NAME: !Ref TweetProcessorFunctionName
BATCH_SIZE: !Ref BatchSize
STREAM_MODE_ENABLED: !Ref StreamModeEnabled
Events:
Timer:
Type: Schedule
Properties:
Schedule: !If [IsPollingFrequencyInMinutesSingular, !Sub 'rate(${PollingFrequencyInMinutes} minute)', !Sub 'rate(${PollingFrequencyInMinutes} minutes)']
SearchCheckpoint:
Type: AWS::Serverless::SimpleTable
Outputs:
TwitterSearchPollerFunctionName:
Value: !Ref TwitterSearchPoller
TwitterSearchPollerFunctionArn:
Value: !GetAtt TwitterSearchPoller.Arn
SearchCheckpointTableName:
Value: !Ref SearchCheckpoint
SearchCheckpointTableArn:
Value: !GetAtt SearchCheckpoint.Arn
Metadata:
AWS::ServerlessRepo::Application:
Name: my-app
Description: twitterpoller2
Author: user1
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE.txt
ReadmeUrl: README.md
Labels: ['tests']
HomePageUrl: https://github.com/thebenjy/astes1.git
SemanticVersion: 0.0.1
SourceCodeUrl: https://github.com/thebenjy/astes1.git
'''
[1]: https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:077246666028:applications~aws-serverless-twitter-event-source
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
