-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔥 bugfix: Security Upgrade blocks
allUsers
need to add tag to suppo…
…rt allowing access publically (#372) * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change * 💽 incremental change
- Loading branch information
1 parent
17c346e
commit 1306e37
Showing
4 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Get input from the environment | ||
* | ||
* @param {Node.env} env | ||
* @param {string} name | ||
* @returns | ||
*/ | ||
function getInput(env, name) { | ||
return env[name]; | ||
} | ||
|
||
/** | ||
* Tag the new Service with the GCP_TAG | ||
* | ||
* @param {object} payload | ||
* @param {object} payload.env | ||
*/ | ||
module.exports = async ({ exec, env }) => { | ||
const gcpProjectId = getInput(env, 'GCP_PROJECT_ID'); | ||
const gcpRegion = getInput(env, 'GCP_REGION'); | ||
const serviceName = getInput(env, 'SERVICE_NAME'); | ||
const gcpTag = getInput(env, 'GCP_TAG'); | ||
|
||
try { | ||
await exec.exec('gcloud', [ | ||
'resource-manager', | ||
'tags', | ||
'bindings', | ||
'create', | ||
`--tag-value=${gcpTag}`, | ||
`--parent=//run.googleapis.com/projects/${gcpProjectId}/locations/${gcpRegion}/services/${serviceName}` | ||
`--location=${gcpRegion}`, | ||
]); | ||
} catch (error) { | ||
console.warn('WARNING: Failed to create resource tag. This may be due to the tag already existing.'); | ||
} | ||
|
||
await exec.exec('gcloud', [ | ||
'run', | ||
'services', | ||
'add-iam-policy-binding', | ||
serviceName, | ||
`--member=allUsers`, | ||
`--role=roles/run.invoker`, | ||
`--region=${gcpRegion}`, | ||
]); | ||
} |