Fix issue using this.bucketName, but the bucket on the service package instead.

Also added the content-type to the json file so you can read the file in the browser.
This commit is contained in:
David Tanner 2016-09-30 08:30:35 -06:00
parent 83dfb88302
commit b97c7176d5
4 changed files with 6 additions and 4 deletions

View File

@ -29,8 +29,8 @@ class AwsCompileFunctions {
throw new Error(`No artifact path is set for function: ${functionName}`);
}
if (this.bucketName) {
newFunction.Properties.Code.S3Bucket = this.bucketName;
if (this.serverless.service.package.deploymentBucket) {
newFunction.Properties.Code.S3Bucket = this.serverless.service.package.deploymentBucket;
}
const s3Folder = this.serverless.service.package.artifactDirectoryName;

View File

@ -290,10 +290,9 @@ describe('AwsCompileFunctions', () => {
it('should use a custom bucket if specified', () => {
const bucketName = 'com.serverless.deploys';
awsCompileFunctions.bucketName = bucketName;
awsCompileFunctions.serverless.service.package.deploymentBucket = bucketName;
awsCompileFunctions.serverless.service.provider.runtime = 'python2.7';
awsCompileFunctions.serverless.service.provider.memorySize = 128;
awsCompileFunctions.serverless.service.provider.deploymentBucket = bucketName;
awsCompileFunctions.serverless.service.functions = {
func: {
handler: 'func.function.handler',

View File

@ -94,6 +94,7 @@ module.exports = {
);
}
this.bucketName = bucketName;
this.serverless.service.package.deploymentBucket = bucketName;
this.serverless.service.provider.compiledCloudFormationTemplate
.Outputs.ServerlessDeploymentBucketName.Value = bucketName;

View File

@ -16,6 +16,7 @@ module.exports = {
Bucket: this.bucketName,
Key: `${this.serverless.service.package.artifactDirectoryName}/${fileName}`,
Body: body,
ContentType: 'application/json',
};
return this.sdk.request('S3',
@ -38,6 +39,7 @@ module.exports = {
Bucket: this.bucketName,
Key: `${this.serverless.service.package.artifactDirectoryName}/${fileName}`,
Body: body,
ContentType: 'application/zip',
};
return this.sdk.request('S3',