mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Update bucket conf to default AES256 encryption and enable versioning.
This commit is contained in:
parent
3b9957f072
commit
3ed18cfb89
@ -3,7 +3,21 @@
|
||||
"Description": "The AWS CloudFormation template for this Serverless application",
|
||||
"Resources": {
|
||||
"ServerlessDeploymentBucket": {
|
||||
"Type" : "AWS::S3::Bucket"
|
||||
"Type" : "AWS::S3::Bucket",
|
||||
"Properties" : {
|
||||
"VersioningConfiguration": {
|
||||
"Status": "Enabled"
|
||||
},
|
||||
"BucketEncryption": {
|
||||
"ServerSideEncryptionConfiguration": [
|
||||
{
|
||||
"ServerSideEncryptionByDefault": {
|
||||
"SSEAlgorithm": "AES256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
|
||||
@ -15,13 +15,13 @@ module.exports = {
|
||||
|
||||
this.serverless.service.provider
|
||||
.compiledCloudFormationTemplate = this.serverless.utils.readFileSync(
|
||||
path.join(this.serverless.config.serverlessPath,
|
||||
'plugins',
|
||||
'aws',
|
||||
'package',
|
||||
'lib',
|
||||
'core-cloudformation-template.json')
|
||||
);
|
||||
path.join(this.serverless.config.serverlessPath,
|
||||
'plugins',
|
||||
'aws',
|
||||
'package',
|
||||
'lib',
|
||||
'core-cloudformation-template.json')
|
||||
);
|
||||
|
||||
const bucketName = this.serverless.service.provider.deploymentBucket;
|
||||
const isS3TransferAccelerationSupported = this.provider.isS3TransferAccelerationSupported();
|
||||
@ -54,27 +54,30 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
const mergeProperties = [];
|
||||
|
||||
if (isS3TransferAccelerationEnabled && isS3TransferAccelerationSupported) {
|
||||
// enable acceleration via CloudFormation
|
||||
this.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ServerlessDeploymentBucket.Properties = {
|
||||
AccelerateConfiguration: {
|
||||
AccelerationStatus: 'Enabled',
|
||||
},
|
||||
};
|
||||
mergeProperties.push({
|
||||
AccelerateConfiguration: {
|
||||
AccelerationStatus: 'Enabled',
|
||||
},
|
||||
});
|
||||
// keep track of acceleration status via CloudFormation Output
|
||||
this.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Outputs.ServerlessDeploymentBucketAccelerated = { Value: true };
|
||||
.Outputs.ServerlessDeploymentBucketAccelerated = { Value: true };
|
||||
} else if (isS3TransferAccelerationDisabled && isS3TransferAccelerationSupported) {
|
||||
// explicitly disable acceleration via CloudFormation
|
||||
this.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ServerlessDeploymentBucket.Properties = {
|
||||
AccelerateConfiguration: {
|
||||
AccelerationStatus: 'Suspended',
|
||||
},
|
||||
};
|
||||
mergeProperties.push({
|
||||
AccelerateConfiguration: {
|
||||
AccelerationStatus: 'Suspended',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(this.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ServerlessDeploymentBucket.Properties, ...mergeProperties);
|
||||
|
||||
const coreTemplateFileName = this.provider.naming.getCoreTemplateFileName();
|
||||
|
||||
const coreTemplateFilePath = path.join(this.serverless.config.servicePath,
|
||||
|
||||
@ -109,9 +109,23 @@ describe('#generateCoreTemplate()', () => {
|
||||
expect(
|
||||
awsPlugin.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ServerlessDeploymentBucket
|
||||
).to.be.deep.equal({
|
||||
Type: 'AWS::S3::Bucket',
|
||||
});
|
||||
).to.be.deep.equal({
|
||||
Type: 'AWS::S3::Bucket',
|
||||
Properties: {
|
||||
VersioningConfiguration: {
|
||||
Status: 'Enabled',
|
||||
},
|
||||
BucketEncryption: {
|
||||
ServerSideEncryptionConfiguration: [
|
||||
{
|
||||
ServerSideEncryptionByDefault: {
|
||||
SSEAlgorithm: 'AES256',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
@ -156,6 +170,18 @@ describe('#generateCoreTemplate()', () => {
|
||||
AccelerateConfiguration: {
|
||||
AccelerationStatus: 'Suspended',
|
||||
},
|
||||
VersioningConfiguration: {
|
||||
Status: 'Enabled',
|
||||
},
|
||||
BucketEncryption: {
|
||||
ServerSideEncryptionConfiguration: [
|
||||
{
|
||||
ServerSideEncryptionByDefault: {
|
||||
SSEAlgorithm: 'AES256',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -172,6 +198,20 @@ describe('#generateCoreTemplate()', () => {
|
||||
const template = serverless.service.provider.coreCloudFormationTemplate;
|
||||
expect(template.Resources.ServerlessDeploymentBucket).to.be.deep.equal({
|
||||
Type: 'AWS::S3::Bucket',
|
||||
Properties: {
|
||||
VersioningConfiguration: {
|
||||
Status: 'Enabled',
|
||||
},
|
||||
BucketEncryption: {
|
||||
ServerSideEncryptionConfiguration: [
|
||||
{
|
||||
ServerSideEncryptionByDefault: {
|
||||
SSEAlgorithm: 'AES256',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -73,6 +73,20 @@ describe('mergeCustomProviderResources', () => {
|
||||
FakeResource2: {
|
||||
FakePropKey: 'FakePropValue',
|
||||
},
|
||||
Properties: {
|
||||
VersioningConfiguration: {
|
||||
Status: 'Enabled',
|
||||
},
|
||||
BucketEncryption: {
|
||||
ServerSideEncryptionConfiguration: [
|
||||
{
|
||||
ServerSideEncryptionByDefault: {
|
||||
SSEAlgorithm: 'AES256',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user