Skip to content

Add sample network-isolation/inbound-webhooks - #560

Open
nbaudis wants to merge 1 commit into
mainfrom
add-network-isolation-inbound-webhooks-sample
Open

nbaudis wants to merge 1 commit into
mainfrom
add-network-isolation-inbound-webhooks-sample

Conversation

@nbaudis

@nbaudis nbaudis commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

This adds a new sample that shows a pattern for receiving webhooks from the public internet in a network-isolated Code Engine application.

@nbaudis
nbaudis requested a review from reggeenr November 26, 2026 21:27
@nbaudis
nbaudis marked this pull request as draft November 27, 2026 13:59
@nbaudis
nbaudis force-pushed the add-network-isolation-inbound-webhooks-sample branch from e777e20 to 7f316f3 Compare November 30, 2026 17:09
@nbaudis
nbaudis marked this pull request as ready for review November 30, 2026 17:09
@nbaudis
nbaudis force-pushed the add-network-isolation-inbound-webhooks-sample branch from 7f316f3 to 1db50cc Compare December 1, 2026 08:30

@reggeenr reggeenr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nbaudis , thanks for providing this great example.

Please see my two remarks regarding the scripts that are providing along with the source code.

Best regards, Rico

Comment on lines +19 to +29
BUILD_PROJECT=${BUILD_PROJECT:-webhook-build}
REGISTRY=${REGISTRY:-icr.io/codeengine/webhook-sample}

ibmcloud ce project get --name "$BUILD_PROJECT" > /dev/null 2>&1 || ibmcloud ce project create --name "$BUILD_PROJECT"
ibmcloud ce project select --name "$BUILD_PROJECT"

suffix=$(date +%y%m%d-%H%M%S)
ibmcloud ce buildrun submit --name "webhook-consumer-$suffix" --source src/consumer --strategy dockerfile \
--image "$REGISTRY/consumer" --wait
ibmcloud ce buildrun submit --name "webhook-receiver-$suffix" --source src/receiver --strategy codebundle-nodejs-24 \
--dockerfile "" --image "$REGISTRY/receiver" --wait

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will potentially break automation, as the automation only has a Container Registry Context and no ability to select a certain project.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss if adding a Code Engine context would be viable. Would be great if the automation was able to submit build runs, also for other function samples requiring code bundles.

Comment on lines +88 to +101
ibmcloud ce project create --name "$ISOLATED_PROJECT"
ISOLATED_GUID=$(ibmcloud ce project get --name "$ISOLATED_PROJECT" --output json | jq -r '.guid')
ibmcloud cbr rule-create --description "Block all inbound traffic to $ISOLATED_PROJECT" \
--service-name codeengine --service-instance "$ISOLATED_GUID" \
--api-types crn:v1:bluemix:public:context-based-restrictions::::api-type:data-plane \
--empty-context-list

# Trusted profiles: the receiver may only write to the bucket, the consumer may only read from it
PUBLIC_TRUSTED_PROFILE_ID=$(ibmcloud iam trusted-profile-create "$PROFILE_PUBLIC" --output json | jq -r '.id')
ISOLATED_TRUSTED_PROFILE_ID=$(ibmcloud iam trusted-profile-create "$PROFILE_ISOLATED" --output json | jq -r '.id')
ibmcloud iam trusted-profile-policy-create "$PROFILE_PUBLIC" --roles "Object Writer" --service-name cloud-object-storage \
--service-instance "$COS_GUID" --resource-type bucket --resource "$BUCKET"
ibmcloud iam trusted-profile-policy-create "$PROFILE_ISOLATED" --roles "Object Reader" --service-name cloud-object-storage \
--service-instance "$COS_GUID" --resource-type bucket --resource "$BUCKET"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this script idempotent.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had thought about this as well, but ended up finding real idempotency too complex. However, it looks like most run scripts in this repo provide idempotency by running clean() first before deploying. I will follow the same pattern for this run script.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants