HttpApi deployment with JWT authorizer does not create routes, integrations, and authorizers with aws-sam-cli 1.8.0
Description:
Creating a simple SAM template with one httpapi resource, a JWT authorizer, and one function does not deploy routes, integrations, or authorizers. Removing the authorizer reference from the function causes routes and integrations to be deployed.
Steps to reproduce:
Use this template file and aws-sam-cli 1.8.0 to build, package, and deploy:
AWSTemplateFormatVersion: '2010-09-09'
Description: Provisions AWS Serverless resources
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyHttpApi:
Type: 'AWS::Serverless::HttpApi'
Properties:
StageName: "dev-v1"
Auth:
Authorizers:
OAuth2Authorizer:
IdentitySource: "$request.headers.Authorization"
AuthorizationScopes:
- email
JwtConfiguration:
issuer: "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_zzzzzzzzz"
audience:
- "abcdefghijklmnopqrstuvsxyz"
HttpApiDispatcher:
Type: 'AWS::Serverless::Function'
Properties:
Description: API function handler
Runtime: python3.8
Timeout: 10
MemorySize: 128
Tracing: Active
AutoPublishAlias: live
FunctionName: "test_dev_v1_dispatcher"
Handler: "bikepump_admin_api.api_dispatcher"
Events:
ApiEventRoot:
Type: HttpApi
Properties:
Path: /{domain}
Method: ANY
ApiId: !Ref MyHttpApi
Auth:
Authorizer: OAuth2Authorizer
Outputs:
StackName:
Description: API Stack Name
Value: !Ref AWS::StackName
Export:
Name: !Sub ${AWS::StackName}-StackName
ApiEndpoint:
Description: API Stage Endpoint
Value: !Sub "https://${MyHttpApi}.execute-api.${AWS::Region}.amazonaws.com"
Export:
Name: !Sub ${AWS::StackName}-ApiEndPoint
Observed result:
2020-11-07 00:54:48,374 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-07 00:54:48,383 | 'build' command is called
2020-11-07 00:54:48,390 | No Parameters detected in the template
2020-11-07 00:54:48,420 | 2 resources found in the template
2020-11-07 00:54:48,420 | Found Serverless function with name='HttpApiDispatcher' and CodeUri='.'
2020-11-07 00:54:48,420 | No Parameters detected in the template
2020-11-07 00:54:48,632 | Instantiating build definitions
2020-11-07 00:54:48,634 | Same build definition found, adding function (Previous: BuildDefinition(python3.8, ., 9e99e91e-71ab-4758-b1c9-552ea268a3c2, {}, []), Current: BuildDefinition(python3.8, ., 570cd08c-9f2f-4db2-80bb-d65643c17ef4, {}, []), Function: Function(name='HttpApiDispatcher', functionname='test_dev_v1_dispatcher', runtime='python3.8', memory=128, timeout=10, handler='bikepump_admin_api.api_dispatcher', codeuri='.', environment=None, rolearn=None, layers=[], events={'ApiEventRoot': {'Type': 'HttpApi', 'Properties': {'Path': '/{domain}', 'Method': 'ANY', 'ApiId': 'MyHttpApi', 'Auth': {'Authorizer': 'OAuth2Authorizer'}}}}, metadata=None))
2020-11-07 00:54:48,635 | Building codeuri: . runtime: python3.8 metadata: {} functions: ['HttpApiDispatcher']
2020-11-07 00:54:48,635 | Building to following folder /Users/jamie/Projects/BikePumpApi/.aws-sam-jbtest/build/HttpApiDispatcher
2020-11-07 00:54:48,635 | Loading workflow module 'aws_lambda_builders.workflows'
2020-11-07 00:54:48,640 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2020-11-07 00:54:48,642 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2020-11-07 00:54:48,644 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2020-11-07 00:54:48,647 | Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2020-11-07 00:54:48,649 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2020-11-07 00:54:48,652 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2020-11-07 00:54:48,654 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2020-11-07 00:54:48,657 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2020-11-07 00:54:48,659 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2020-11-07 00:54:48,659 | Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2020-11-07 00:54:48,712 | Running workflow 'PythonPipBuilder'
2020-11-07 00:54:48,713 | Running PythonPipBuilder:ResolveDependencies
2020-11-07 00:54:48,771 | calling pip download -r /Users/jamie/Projects/BikePumpApi/artwork_json_trigger/requirements.txt --dest /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d
2020-11-07 00:54:53,414 | calling pip wheel --no-deps --wheel-dir /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d ./stdapplib
2020-11-07 00:54:55,226 | Full dependency closure: {certifi==2019.11.28(wheel), aws-xray-sdk==2.4.3(wheel), idna==2.10(wheel), urllib3==1.25.11(wheel), six==1.13.0(wheel), zipp==3.4.0(wheel), python-dateutil==2.8.1(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), importlib-metadata==2.0.0(wheel), future==0.18.2(sdist), botocore==1.14.17(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), docutils==0.15.2(wheel), wrapt==1.11.2(sdist), jmespath==0.9.5(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel)}
2020-11-07 00:54:55,226 | initial compatible: {certifi==2019.11.28(wheel), six==1.13.0(wheel), aws-xray-sdk==2.4.3(wheel), zipp==3.4.0(wheel), botocore==1.14.17(wheel), jmespath==0.9.5(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), idna==2.10(wheel), docutils==0.15.2(wheel), python-dateutil==2.8.1(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), urllib3==1.25.11(wheel), importlib-metadata==2.0.0(wheel)}
2020-11-07 00:54:55,226 | initial incompatible: {wrapt==1.11.2(sdist), future==0.18.2(sdist)}
2020-11-07 00:54:55,226 | Downloading missing wheels: {wrapt==1.11.2(sdist), future==0.18.2(sdist)}
2020-11-07 00:54:55,226 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp38 --dest /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d wrapt==1.11.2
2020-11-07 00:54:55,746 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp38 --dest /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d future==0.18.2
2020-11-07 00:54:56,287 | compatible wheels after second download pass: {certifi==2019.11.28(wheel), aws-xray-sdk==2.4.3(wheel), six==1.13.0(wheel), zipp==3.4.0(wheel), botocore==1.14.17(wheel), jmespath==0.9.5(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), docutils==0.15.2(wheel), idna==2.10(wheel), python-dateutil==2.8.1(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), urllib3==1.25.11(wheel), importlib-metadata==2.0.0(wheel)}
2020-11-07 00:54:56,287 | Build missing wheels from sdists (C compiling True): {wrapt==1.11.2(sdist), future==0.18.2(sdist)}
2020-11-07 00:54:56,287 | calling pip wheel --no-deps --wheel-dir /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d/wrapt-1.11.2.tar.gz
2020-11-07 00:54:57,739 | calling pip wheel --no-deps --wheel-dir /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d/future-0.18.2.tar.gz
2020-11-07 00:54:59,197 | compatible after building wheels (no C compiling): {certifi==2019.11.28(wheel), aws-xray-sdk==2.4.3(wheel), six==1.13.0(wheel), zipp==3.4.0(wheel), importlib-metadata==2.0.0(wheel), botocore==1.14.17(wheel), jmespath==0.9.5(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), docutils==0.15.2(wheel), idna==2.10(wheel), python-dateutil==2.8.1(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), urllib3==1.25.11(wheel), future==0.18.2(wheel)}
2020-11-07 00:54:59,197 | Build missing wheels from sdists (C compiling False): {wrapt==1.11.2(sdist)}
2020-11-07 00:54:59,198 | calling pip wheel --no-deps --wheel-dir /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d /var/folders/4k/m_c5978n55n9c0f69d2kbwd80000gn/T/tmp7kk4sl5d/wrapt-1.11.2.tar.gz
2020-11-07 00:55:00,157 | compatible after building wheels (C compiling): {certifi==2019.11.28(wheel), aws-xray-sdk==2.4.3(wheel), idna==2.10(wheel), urllib3==1.25.11(wheel), six==1.13.0(wheel), zipp==3.4.0(wheel), python-dateutil==2.8.1(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), importlib-metadata==2.0.0(wheel), future==0.18.2(wheel), botocore==1.14.17(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), docutils==0.15.2(wheel), wrapt==1.11.2(wheel), jmespath==0.9.5(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel)}
2020-11-07 00:55:00,158 | Final compatible: {certifi==2019.11.28(wheel), aws-xray-sdk==2.4.3(wheel), botocore==1.14.17(wheel), s3transfer==0.3.3(wheel), stdapplib==0.1(wheel), idna==2.10(wheel), docutils==0.15.2(wheel), future==0.18.2(wheel), wrapt==1.11.2(wheel), urllib3==1.25.11(wheel), six==1.13.0(wheel), zipp==3.4.0(wheel), jmespath==0.9.5(wheel), python-dateutil==2.8.1(wheel), jsonpickle==1.4.1(wheel), chardet==3.0.4(wheel), boto3==1.11.17(wheel), ptvsd==4.3.2(wheel), importlib-metadata==2.0.0(wheel)}
2020-11-07 00:55:00,158 | Final incompatible: {wrapt==1.11.2(wheel)}
2020-11-07 00:55:00,158 | Final missing wheels: set()
2020-11-07 00:55:00,855 | PythonPipBuilder:ResolveDependencies succeeded
2020-11-07 00:55:00,855 | Running PythonPipBuilder:CopySource
2020-11-07 00:55:00,860 | PythonPipBuilder:CopySource succeeded
Build Succeeded
Built Artifacts : .aws-sam-jbtest/build
Built Template : .aws-sam-jbtest/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke -t .aws-sam-jbtest/build/template.yaml
[*] Deploy: sam deploy --guided --template-file .aws-sam-jbtest/build/template.yaml
2020-11-07 00:55:00,867 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 12492, 'exitReason': 'success', 'exitCode': 0, 'requestId': '713720b5-0af7-4724-8e17-e4b392ed6844', 'installationId': '07d3d29b-e32f-4695-b32c-d2f628993df1', 'sessionId': 'e1d7ea6c-b6b8-4be9-8799-9b1e7e2a4ed4', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.8.0'}}]}
2020-11-07 00:55:01,327 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2020-11-07 00:55:01,671 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-07 00:55:01,672 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-07 00:55:01,672 | Sending Telemetry: {'metrics': [{'templateWarning': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'warningName': 'CodeDeployWarning', 'warningCount': 0, 'requestId': '5102a276-ea36-4be9-9b9a-1e87dbff4d82', 'installationId': '07d3d29b-e32f-4695-b32c-d2f628993df1', 'sessionId': 'f0727003-8f6d-441f-a250-d6a3b7444595', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.8.0'}}]}
2020-11-07 00:55:02,080 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2020-11-07 00:55:02,081 | Sending Telemetry: {'metrics': [{'templateWarning': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'warningName': 'CodeDeployConditionWarning', 'warningCount': 0, 'requestId': '3375ea04-0296-47ed-819b-548644f8287a', 'installationId': '07d3d29b-e32f-4695-b32c-d2f628993df1', 'sessionId': 'f0727003-8f6d-441f-a250-d6a3b7444595', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.8.0'}}]}
2020-11-07 00:55:02,488 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2020-11-07 00:55:05,063 | File with same data is already exists at artwork_json_trigger/d5d0180e2d496e36faeedee7599330bf. Skipping upload
Successfully packaged artifacts and wrote output template to file .aws-sam-jbtest/generated_httpapi_template.yaml.
Execute the following command to deploy the packaged template
sam deploy --template-file /Users/jamie/Projects/BikePumpApi/.aws-sam-jbtest/generated_httpapi_template.yaml --stack-name <YOUR STACK NAME>
2020-11-07 00:55:05,072 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam package', 'duration': 3399, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'a96d4114-756a-4a05-b2cc-b5dd522468c0', 'installationId': '07d3d29b-e32f-4695-b32c-d2f628993df1', 'sessionId': 'f0727003-8f6d-441f-a250-d6a3b7444595', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.8.0'}}]}
2020-11-07 00:55:05,464 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2020-11-07 00:55:05,843 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-11-07 00:55:06,254 | Property CodeUri of HttpApiDispatcher is already a S3 URL
Deploying with following values
===============================
Stack name : jbtest-stack
Region : None
Confirm changeset : False
Deployment s3 bucket : None
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {'AppName': 'bikepump', 'ApiName': 'admin', 'ApiVersion': 'v1', 'EnvType': 'dev', 'CognitoStackName': 'dev-bikepump-admin-cognito-stack', 'DatabaseStackName': 'dev-bikepump-rds-stack', 'DatabaseBatchSize': '250', 'LambdaLogLevel': 'DEBUG', 'XRaySdkEnabled': 'true', 'MockDatabaseResponses': 'false', 'CertificateArn': 'arn:aws:acm:us-east-1:933087706014:certificate/6e9564c9-4c7c-414d-ae5c-399dea56b816', 'CustomDomainName': 'bikepump.com', 'AppRegion': 'us-east-1', 'InputBucketName': 'dev-bikepump-input', 'OutputBucketName': 'dev-bikepump-output', 'PrivateBucketName': 'dev-bikepump-private', 'PublicBucketName': 'dev-bikepump-public', 'TaskArnPrefix': 'arn:aws:states:us-east-1:933087706014:stateMachine:dev_bikepump_'}
Initiating deployment
=====================
2020-11-07 00:55:06,349 | No Parameters detected in the template
2020-11-07 00:55:06,377 | 2 resources found in the template
2020-11-07 00:55:06,377 | Found Serverless function with name='HttpApiDispatcher' and CodeUri='.'
2020-11-07 00:55:06,594 | Stack with id jbtest-stack does not exist
Waiting for changeset to be created..
CloudFormation stack changeset
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Add HttpApiDispatcherAliaslive AWS::Lambda::Alias N/A
+ Add HttpApiDispatcherApiEventRootPermission AWS::Lambda::Permission N/A
+ Add HttpApiDispatcherRole AWS::IAM::Role N/A
+ Add HttpApiDispatcherVersioncf40d16aa4 AWS::Lambda::Version N/A
+ Add HttpApiDispatcher AWS::Lambda::Function N/A
+ Add MyHttpApiStage24074bc2fb AWS::ApiGatewayV2::Stage N/A
+ Add MyHttpApi AWS::ApiGatewayV2::Api N/A
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation:us-east-1:933087706014:changeSet/samcli-deploy1604732106/ea621faa-aa93-413e-907e-9563ee32fa85
2020-11-07 00:55:17 - Waiting for stack create/update to complete
CloudFormation events from changeset
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::IAM::Role HttpApiDispatcherRole -
CREATE_IN_PROGRESS AWS::IAM::Role HttpApiDispatcherRole Resource creation Initiated
CREATE_COMPLETE AWS::IAM::Role HttpApiDispatcherRole -
CREATE_IN_PROGRESS AWS::Lambda::Function HttpApiDispatcher -
CREATE_IN_PROGRESS AWS::Lambda::Function HttpApiDispatcher Resource creation Initiated
CREATE_COMPLETE AWS::Lambda::Function HttpApiDispatcher -
CREATE_IN_PROGRESS AWS::Lambda::Version HttpApiDispatcherVersioncf40d16aa4 -
CREATE_IN_PROGRESS AWS::Lambda::Version HttpApiDispatcherVersioncf40d16aa4 Resource creation Initiated
CREATE_COMPLETE AWS::Lambda::Version HttpApiDispatcherVersioncf40d16aa4 -
CREATE_IN_PROGRESS AWS::Lambda::Alias HttpApiDispatcherAliaslive -
CREATE_COMPLETE AWS::Lambda::Alias HttpApiDispatcherAliaslive -
CREATE_IN_PROGRESS AWS::Lambda::Alias HttpApiDispatcherAliaslive Resource creation Initiated
CREATE_IN_PROGRESS AWS::ApiGatewayV2::Api MyHttpApi -
CREATE_COMPLETE AWS::ApiGatewayV2::Api MyHttpApi -
CREATE_IN_PROGRESS AWS::ApiGatewayV2::Api MyHttpApi Resource creation Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission HttpApiDispatcherApiEventRootPermission Resource creation Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission HttpApiDispatcherApiEventRootPermission -
CREATE_IN_PROGRESS AWS::ApiGatewayV2::Stage MyHttpApiStage24074bc2fb -
CREATE_COMPLETE AWS::ApiGatewayV2::Stage MyHttpApiStage24074bc2fb -
CREATE_IN_PROGRESS AWS::ApiGatewayV2::Stage MyHttpApiStage24074bc2fb Resource creation Initiated
CREATE_COMPLETE AWS::Lambda::Permission HttpApiDispatcherApiEventRootPermission -
CREATE_COMPLETE AWS::CloudFormation::Stack jbtest-stack -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CloudFormation outputs from deployed stack
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Outputs
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key ApiEndpoint
Description API Stage Endpoint
Value https://b78pllshc8.execute-api.us-east-1.amazonaws.com
Key StackName
Description API Stack Name
Value jbtest-stack
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Successfully created/updated stack - jbtest-stack in None
2020-11-07 00:56:04,799 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam deploy', 'duration': 58954, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'e18bfdca-ce3e-40ce-9223-d228cc910a36', 'installationId': '07d3d29b-e32f-4695-b32c-d2f628993df1', 'sessionId': '1e031da2-08b3-48d1-940a-624128916bbe', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.8.0'}}]}
2020-11-07 00:56:05,204 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Expected result:
Expect routes, integrations, and authorizers to be created with the deployment. Commenting out the authorizer reference in the function definition causes routes and integrations to be created, but obviously without the authorizer.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOS 10.15.8
sam --version: 1.8.0
Add --debug flag to command you are running
Facing same issue. Please help here. Is there any work-around for this?
Same issue here. This ticket is from 7 months ago, is there any progress on it?
Checking in nearly a year later, encountering the same issue.
I encountered this myself - it looks like it must have an audience specified otherwise the route is not created.
e.g.
HTTPApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: "yourStage"
Auth:
DefaultAuthorizer: CognitoAuth
Authorizers:
CognitoAuth:
IdentitySource: "$request.header.Authorization"
JwtConfiguration:
issuer: !Sub https://cognito-idp.${AWS::Region}.amazonaws.com/${UserPoolId}
audience:
- youraudience
CorsConfiguration:
AllowMethods:
- GET
- POST
AllowOrigins:
- "https://*"
-
I'm having this issue also. Hoping there is a resolution soon. @DecMcLaughlin I have an audience defined as well, but still having the issue.
I was able to resolve my issue after reading this thread here https://github.com/aws/serverless-application-model/issues/2689. The solution worked for me, since I was indeed capitalizing Issuer and Audience in the JwtConfig, when they in fact need to be all lower case.
However, it appears that you already have them lower-cased though. In that case, the same thread also provides a handy alternative workaround where you add an explicit AWS::ApiGatewayV2::Authorizer resource with the same name as the implicit one defined within you HttpApi section. Give that a try!
Hi there, sorry for the delayed response.
I looked into this issue and I could verify that no route or authorizer is created with the template you provided. I immediately added FailOnWarnings property to AWS::Serverless::HttpApi and set it to true. I also highly recommend to have this property set to True for debugging purposes.
What I found out is that there are actually a couple warnings when trying to deploy the AWS::ApiGateway::HttpApi in the template you provided. Here is one of the warnings. This issue is because IdentitySource: "$request.headers.Authorization" incorrectly used headers (should have been header). Updated it to IdentitySource: "$request.header.Authorization" silenced this warning.
I made a couple of modification to your template and I was able to deploy HttpApi and JWT Authorizer with routes, integration, and authorizers. Please take a look at the updated template:
AWSTemplateFormatVersion: '2010-09-09'
Description: Provisions AWS Serverless resources
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyHttpApi:
Type: 'AWS::Serverless::HttpApi'
Properties:
StageName: "dev-v1"
FailOnWarnings: True
Auth:
Authorizers:
OAuth2Authorizer:
IdentitySource: "$request.header.Authorization"
AuthorizationScopes:
- email
JwtConfiguration:
issuer: !Sub "https://cognito-idp.us-west-2.amazonaws.com/${MyCognitoUserPool}"
audience:
- !Ref MyCognitoUserPoolClient
HttpApiDispatcher:
Type: 'AWS::Serverless::Function'
Properties:
Description: API function handler
Runtime: python3.8
Timeout: 10
MemorySize: 128
Tracing: Active
AutoPublishAlias: live
Handler: "bikepump_admin_api.api_dispatcher"
Events:
ApiEventRoot:
Type: HttpApi
Properties:
Path: /{domain}
Method: ANY
ApiId: !Ref MyHttpApi
Auth:
Authorizer: OAuth2Authorizer
MyCognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: MyCognitoUserPool
MyCognitoUserPoolClient:
Type: AWS::Cognito::UserPoolClient
Properties:
UserPoolId:
Ref: MyCognitoUserPool
ClientName: MyCognitoUserPoolClient
GenerateSecret: false
Outputs:
StackName:
Description: API Stack Name
Value: !Ref AWS::StackName
Export:
Name: !Sub ${AWS::StackName}-StackName
ApiEndpoint:
Description: API Stage Endpoint
Value: !Sub "https://${MyHttpApi}.execute-api.${AWS::Region}.amazonaws.com"
Export:
Name: !Sub ${AWS::StackName}-ApiEndPoint
Also I want to add a note that SAM originally didn't support upper-case Issuer and Audience in jwt-configuration. However, this was updated and these two properties are now case-insensitive.
@jamie-burks @nitishSa @tj-kev @crrice Again apologize for the late response. If you're still experiencing this issue, please look at the above working template. Feel free to reach out if you encounter any new problems.
I'm going to close this issue as it doesn't seem to be a bug. If you still have trouble, feel free to cut a new issue and link this issue.