Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions package/lib/compileFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = {
validateHandlerProperty(funcObject, functionName);
validateEventsProperty(funcObject, functionName);
validateVpcConnectorProperty(funcObject, functionName);
validateIamProperty(funcObject, functionName);

const funcTemplate = getFunctionTemplate(
funcObject,
Expand Down Expand Up @@ -52,11 +51,6 @@ module.exports = {
_.get(this, 'serverless.service.provider.environment'),
funcObject.environment // eslint-disable-line comma-dangle
);
funcTemplate.accessControl.gcpIamPolicy.bindings = _.unionBy(
_.get(funcObject, 'iam.bindings'),
_.get(this, 'serverless.service.provider.iam.bindings'),
'role'
);

if (!funcTemplate.properties.serviceAccountEmail) {
delete funcTemplate.properties.serviceAccountEmail;
Expand Down Expand Up @@ -89,14 +83,6 @@ module.exports = {

funcTemplate.properties.httpsTrigger = {};
funcTemplate.properties.httpsTrigger.url = url;

if (funcObject.allowUnauthenticated) {
funcTemplate.accessControl.gcpIamPolicy.bindings = _.unionBy(
[{ role: 'roles/cloudfunctions.invoker', members: ['allUsers'] }],
funcTemplate.accessControl.gcpIamPolicy.bindings,
'role'
);
}
}
if (eventType === 'event') {
const type = funcObject.events[0].event.eventType;
Expand All @@ -109,10 +95,6 @@ module.exports = {
funcTemplate.properties.eventTrigger.resource = resource;
}

if (!funcTemplate.accessControl.gcpIamPolicy.bindings.length) {
delete funcTemplate.accessControl;
}

this.serverless.service.provider.compiledConfigurationTemplate.resources.push(funcTemplate);
});

Expand Down Expand Up @@ -175,29 +157,6 @@ const validateVpcConnectorProperty = (funcObject, functionName) => {
}
};

const validateIamProperty = (funcObject, functionName) => {
if (_.get(funcObject, 'iam.bindings') && funcObject.iam.bindings.length > 0) {
funcObject.iam.bindings.forEach((binding) => {
if (!binding.role) {
const errorMessage = [
`The function "${functionName}" has no role specified for an IAM binding.`,
' Each binding requires a role. For details on supported roles, see the documentation',
' at: https://cloud.google.com/iam/docs/understanding-roles',
].join('');
throw new Error(errorMessage);
}
if (!Array.isArray(binding.members) || !binding.members.length) {
const errorMessage = [
`The function "${functionName}" has no members specified for an IAM binding.`,
' Each binding requires at least one member to be assigned. See the IAM documentation',
' for details on configuring members: https://cloud.google.com/iam/docs/overview',
].join('');
throw new Error(errorMessage);
}
});
}
};

const getFunctionTemplate = (funcObject, projectName, region, sourceArchiveUrl) => {
//eslint-disable-line
return {
Expand All @@ -212,10 +171,5 @@ const getFunctionTemplate = (funcObject, projectName, region, sourceArchiveUrl)
function: funcObject.name,
sourceArchiveUrl,
},
accessControl: {
gcpIamPolicy: {
bindings: [],
},
},
};
};
Loading