Skip to content

Commit

Permalink
Merge 2d70cbe into 1864969
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Jul 15, 2021
2 parents 1864969 + 2d70cbe commit a590604
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
8 changes: 8 additions & 0 deletions docs/deprecations.md
Expand Up @@ -36,6 +36,14 @@ Note:
- In service configuration setting is ineffective for deprecations reported before service configuration is read.
- `SLS_DEPRECATION_DISABLE` env var and `disabledDeprecations` configuration setting remain respected, and no errors will be thrown for mentioned deprecation coodes.

<a name="DISABLE_DEFAULT_OUTPUT_EXPORT_NAMES"><div>&nbsp;</div></a>

## Disable default Output Export names

Deprecation code: `DISABLE_DEFAULT_OUTPUT_EXPORT_NAMES`

Starting with `v3.0.0`, it will not be possible to disable default export names for outputs. To hide this deprecation message and ensure seamless upgrade, please remove this flag.

<a name="CLI_DEPLOY_FUNCTION_OPTION"><div>&nbsp;</div></a>

## CLI `--function`/`-f` option for `deploy` command
Expand Down
1 change: 1 addition & 0 deletions docs/providers/aws/guide/serverless.yml.md
Expand Up @@ -63,6 +63,7 @@ provider:
key1: value1
key2: value2
deploymentPrefix: serverless # The S3 prefix under which deployed artifacts should be stored. Default is serverless
disableDefaultOutputExportNames: true # optional, allows to disable default behavior of generating export names for CloudFormation outputs
lambdaHashingVersion: 20201221 # optional, version of hashing algorithm that should be used by the framework
ecr:
scanOnPush: true
Expand Down
11 changes: 10 additions & 1 deletion lib/plugins/aws/package/index.js
Expand Up @@ -64,7 +64,16 @@ class AwsPackage {
.then(() => this.serverless.pluginManager.spawn('aws:common:validate'))
.then(() => this.serverless.pluginManager.spawn('aws:common:cleanupTempDir')),

'package:initialize': async () => this.generateCoreTemplate(),
'package:initialize': async () => {
if (this.serverless.service.provider.disableDefaultOutputExportNames) {
this.serverless._logDeprecation(
'DISABLE_DEFAULT_OUTPUT_EXPORT_NAMES',
'Starting with `v3.0.0`, it will not be possible to disable default export names for outputs. To hide this deprecation message and ensure seamless upgrade, please remove this flag.'
);
}

return this.generateCoreTemplate();
},

'package:setupProviderConfiguration': () => this.mergeIamTemplates(),

Expand Down
14 changes: 8 additions & 6 deletions lib/plugins/aws/package/lib/addExportNameForOutputs.js
Expand Up @@ -2,12 +2,14 @@

module.exports = {
addExportNameForOutputs() {
const outputs = this.serverless.service.provider.compiledCloudFormationTemplate.Outputs;
for (const [key, data] of Object.entries(outputs)) {
if (!data.Export) {
data.Export = {
Name: `sls-${this.serverless.service.service}-${this.provider.getStage()}-${key}`,
};
if (!this.serverless.service.provider.disableDefaultOutputExportNames) {
const outputs = this.serverless.service.provider.compiledCloudFormationTemplate.Outputs;
for (const [key, data] of Object.entries(outputs)) {
if (!data.Export) {
data.Export = {
Name: `sls-${this.serverless.service.service}-${this.provider.getStage()}-${key}`,
};
}
}
}
},
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/aws/provider.js
Expand Up @@ -832,6 +832,7 @@ class AwsProvider {
],
},
deploymentPrefix: { type: 'string' },
disableDefaultOutputExportNames: { const: true },
endpointType: {
anyOf: ['REGIONAL', 'EDGE', 'PRIVATE'].map(caseInsensitive),
},
Expand Down
Expand Up @@ -47,4 +47,18 @@ describe('test/unit/lib/plugins/aws/package/lib/addExportNameForOutputs.test.js'
it('Should not override Export.Name for user configured Outputs', () => {
expect(outputs.CustomOutput.Export.Name).to.equal('someExportName');
});

it('Should not add Export.Name if `provider.disableDefaultOutputExportNames` set to `true`', async () => {
const { cfTemplate } = await runServerless({
fixture: 'apiGateway',
command: 'package',
configExt: {
disabledDeprecations: ['DISABLE_DEFAULT_OUTPUT_EXPORT_NAMES'],
provider: {
disableDefaultOutputExportNames: true,
},
},
});
expect(Object.values(cfTemplate.Outputs).some((value) => value.Export)).to.be.false;
});
});

0 comments on commit a590604

Please sign in to comment.