Skip to content

Commit

Permalink
Merge pull request #196 from p1nkun1c0rns/support-direct-vpc-egress
Browse files Browse the repository at this point in the history
Support direct VPC egress
  • Loading branch information
steinbrueckri committed Apr 3, 2024
2 parents dba814f + 6639604 commit 19a0df0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ A Github Action that deploys a service to Google Cloud Run (GCP managed Knative-
| `no_traffic` | Set to true to just deploy a new revision without shifting traffic | `false` | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--no-traffic) |
| `cloudsql_instances` | Comma separated list of CloudSQL instances to connect to | | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--set-cloudsql-instances) |
| `vpc_connector` | Name of the Serverless VPC Access connector to use with this service | | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--vpc-connector) |
| `vpc_egress` | Outbound traffic configuration, if a vpc_connector is configured; options are: `private-ranges-only`, `all-traffic` | `private-ranges-only` | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--vpc-egress) |
| `ingress` | Allowed ingress traffic sources; options are: `all`, `internal`, `internal-and-cloud-load-balancing` | `all` | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--ingress) |
| `vpc_egress` | Outbound traffic configuration, if a vpc_connector is configured; options are: `private-ranges-only`, `all-traffic` | `private-ranges-only` | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--vpc-egress) |
| `vpc_network` | Name of VPC network when using direct VPC egress w/o vpc connector | | false | [gcloud run deploy](https://cloud.google.com/run/docs/configuring/vpc-direct-vpc#direct-vpc-service) |
| `vpc_subnet` | Name of VPC network's subnet when using direct VPC egress w/o vpc connector | | false | [gcloud run deploy](https://cloud.google.com/run/docs/configuring/vpc-direct-vpc#direct-vpc-service) |
| `vpc_network_tags` | Comma-separated list of network tags for the VPC network to be used | | false | [gcloud run deploy](https://cloud.google.com/run/docs/configuring/vpc-direct-vpc#direct-vpc-service)|
| `ingress` | Allowed ingress traffic sources; options are: `all`, `internal`, `internal-and-cloud-load-balancing` | `all` | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--ingress) |
| `execution_environment` | Selects the execution environment where the application will run; options are: `gen1`, `gen2` | | false | [gcloud run deploy](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--execution-environment), [cloud run docs](https://cloud.google.com/run/docs/about-execution-environments) |
| `debug` | Whether the gcloud commands should be printed to output | `false` | false | |

Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ inputs:
description: 'Outbound traffic configuration, if a vpc_connector is configured'
required: false
default: 'private-ranges-only'
vpc_network:
description: 'Name of VPC network when using direct VPC egress'
required: false
default: ''
vpc_subnet:
description: 'Name of VPC network''s subnet'
required: false
default: ''
vpc_network_tags:
description: 'Comma-separated list of network tags'
required: false
default: ''
ingress:
description: 'Allowed ingress traffic sources'
required: false
Expand Down
25 changes: 25 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ if [ -n "$INPUT_VPC_CONNECTOR" ]; then
fi
fi

# Network and Network Tags can/must be cleared. There is no --clear-subnet flag
# At most one of --clear-network | --network --subnet --clear-network-tags | --network-tags can be specified
VPC_NETWORK="--clear-network"
VPC_SUBNET=""
VPC_NETWORK_TAGS=""

if [ -n "$INPUT_VPC_NETWORK" ]; then
VPC_NETWORK="--network=$INPUT_VPC_NETWORK"
VPC_NETWORK_TAGS="--clear-network-tags" # if VPC_NETWORK is set and NETWORK_TAGS is not

if [ -n "$INPUT_VPC_SUBNET" ]; then
VPC_SUBNET="--subnet=$INPUT_VPC_SUBNET"
fi

if [ -n "$INPUT_VPC_NETWORK_TAGS" ]; then
VPC_NETWORK_TAGS="--network-tags=$INPUT_VPC_NETWORK_TAGS"
fi

if [ -n "${INPUT_VPC_EGRESS}" ]; then
VPC_EGRESS="--vpc-egress=$INPUT_VPC_EGRESS"
fi

fi

INGRESS=""
if [ -n "$INPUT_INGRESS" ]; then
INGRESS="--ingress=$INPUT_INGRESS"
Expand Down Expand Up @@ -193,6 +217,7 @@ gcloud beta run deploy "$SERVICE_NAME" \
$SERVICE_ACCOUNT \
$CLOUDSQL_INSTANCES \
$VPC_CONNECTOR $VPC_EGRESS \
$VPC_NETWORK $VPC_SUBNET $VPC_NETWORK_TAGS \
$INGRESS \
$EXECUTION_ENVIRONMENT \
$ENV_VARS \
Expand Down

0 comments on commit 19a0df0

Please sign in to comment.