Skip to content

Commit

Permalink
Merge branch 'master' into MarinaMeza-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinaMeza committed Dec 21, 2021
2 parents 2ad67c4 + 2782ed4 commit cbf7616
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 345 deletions.
4 changes: 3 additions & 1 deletion docs/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ Deprecation code: `AWS_API_GATEWAY_NON_APPLICABLE_SETTINGS`

When external API Gateway resource is used and imported via `provider.apiGateway.restApiId` setting, both `provider.logs.restApi` and `provider.tracing.apiGateway` are ignored. In v3, an error will be thrown if these options are defined. Indeed, these settings are applicable only if API Gateway resource is provisioned by Serverless Framework.

<a name="CLI_OPTIONS_SCHEMA'"><div>&nbsp;</div></a>
<a name="CLI_OPTIONS_SCHEMA"><div>&nbsp;</div></a>

## CLI Options extensions, `type` requirement

Deprecation code: `CLI_OPTIONS_SCHEMA`

_Note: We've resigned from this deprecation in the context of v2 (it'll be re-added in the context of v3). We continue to advise upgrade so schema for CLI options is provided._

Internal handling of CLI arguments was improved with type awareness for options. Now each option definition is expected have `type` defined in its settings.

Possible values are `string`, `boolean` and `multiple`. Check [Defining options](/framework/docs/providers/aws/guide/plugins#defining-options) documentation for more info.
Expand Down
2 changes: 2 additions & 0 deletions docs/providers/aws/guide/serverless.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ provider:
id: 'my-id' # If we want to attach to externally created HTTP API its id should be provided here
name: 'dev-my-service' # Use custom name for the API Gateway API, default is ${sls:stage}-${self:service}
payload: '2.0' # Specify payload format version for Lambda integration ('1.0' or '2.0'), default is '2.0'
disableDefaultEndpoint: false # Specify whether clients can invoke your API by using the default `execute-api` endpoint
metrics: true # Enable detailed metrics
cors: true # Implies default behavior, can be fine tuned with specific options
authorizers:
# JWT authorizer to back HTTP API endpoints
Expand Down
7 changes: 4 additions & 3 deletions lib/configuration/variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ServerlessError = require('../../serverless-error');
const resolveMeta = require('./resolve-meta');
const resolve = require('./resolve');

const sources = {
const defaultSources = {
env: require('./sources/env'),
file: require('./sources/file'),
opt: require('./sources/opt'),
Expand All @@ -33,7 +33,7 @@ const reportEventualErrors = (variablesMeta) => {
);
};

module.exports = async ({ serviceDir, servicePath, configuration, options }) => {
module.exports = async ({ serviceDir, servicePath, configuration, options, sources = null }) => {
// TODO: Remove support for `servicePath` with next major
serviceDir = ensureString(serviceDir || servicePath);
ensurePlainObject(configuration);
Expand All @@ -42,13 +42,14 @@ module.exports = async ({ serviceDir, servicePath, configuration, options }) =>
const variablesMeta = resolveMeta(configuration);
reportEventualErrors(variablesMeta);

if (!sources) sources = defaultSources;
await resolve({
serviceDir,
configuration,
variablesMeta,
sources,
options,
fulfilledSources: new Set(['env', 'file', 'opt', 'self', 'strToBool']),
fulfilledSources: new Set(Object.keys(sources)),
});

reportEventualErrors(variablesMeta);
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/invokeLocal/runtimeWrappers/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j</artifactId>
<version>1.0.1</version>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
Expand Down
4 changes: 3 additions & 1 deletion lib/plugins/aws/package/compile/events/apiGateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ const authorizerSchema = {
resultTtlInSeconds: { type: 'integer', minimum: 0, maximum: 3600 },
scopes: { type: 'array', items: { type: 'string' } },
type: {
anyOf: ['token', 'cognito_user_pools', 'request', 'aws_iam'].map(caseInsensitive),
anyOf: ['token', 'cognito_user_pools', 'request', 'aws_iam', 'custom'].map(
caseInsensitive
),
},
},
required: [],
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/create/templates/aws-java-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.16.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {
'org.jetbrains.kotlin:kotlin-stdlib:1.3.72',
'com.amazonaws:aws-lambda-java-core:1.2.1',
'com.amazonaws:aws-lambda-java-log4j2:1.5.0',
'org.apache.logging.log4j:log4j-api:2.13.3',
'org.apache.logging.log4j:log4j-core:2.13.3',
'org.apache.logging.log4j:log4j-api:2.17.0',
'org.apache.logging.log4j:log4j-core:2.17.0',
'com.fasterxml.jackson.core:jackson-core:2.11.0',
'com.fasterxml.jackson.core:jackson-databind:2.11.0',
'com.fasterxml.jackson.core:jackson-annotations:2.11.0'
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/create/templates/aws-kotlin-jvm-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.16.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,4 +1508,67 @@ describe('test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/valida
'API_GATEWAY_MISSING_REST_API_ROOT_RESOURCE_ID'
);
});

it('should throw when using a CUSTOM authorizer without an authorizer id', async () => {
await expect(
runServerless({
fixture: 'function',
command: 'package',
configExt: {
functions: {
first: {
handler: 'index.handler',
events: [
{
http: {
method: 'POST',
path: '/custom-authorizer',
integration: 'lambda-proxy',
authorizer: {
type: 'CUSTOM',
},
},
},
],
},
},
},
})
).to.be.eventually.rejected.and.have.property(
'code',
'API_GATEWAY_MISSING_AUTHORIZER_NAME_OR_ARN'
);
});

it('should not throw when using CUSTOM authorizer with an authorizer id', async () => {
const result = await runServerless({
fixture: 'function',
command: 'package',
configExt: {
functions: {
first: {
handler: 'index.handler',
events: [
{
http: {
method: 'POST',
path: '/custom-authorizer',
integration: 'lambda-proxy',
authorizer: {
type: 'CUSTOM',
authorizerId: 'MyAuthorizerId',
},
},
},
],
},
},
},
});

cfResources = result.cfTemplate.Resources;
naming = result.awsNaming;
const resource = getApiGatewayMethod('/custom-authorizer', 'POST');
expect(resource.Properties.AuthorizationType).to.equal('CUSTOM');
});
});

0 comments on commit cbf7616

Please sign in to comment.