Skip to content

A Flask web service that lets students get temporary access to IBM PowerVS. I designed it to be simple and secure. It runs on IBM Code Engine (serverless) and can scale with demand.

Notifications You must be signed in to change notification settings

upenr/python-powervs-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Student Invite API

This is a Flask web service that allows students to request temporary access to an IBM Cloud PowerVS account.
When a student calls the /invite endpoint with their email address, the service automatically:

  • Invites the user to the IBM Cloud account.
  • Adds them to my IBM Cloud access group.
  • Creates a time-limited IAM policy (default: 7 days) that restricts their access to the target resource group.

Prerequisites

  • Python 3.9+ (for local runs)
  • IBM Cloud account with IAM admin rights
  • An IBM API key with authority to invite users and assign IAM policies
  • A configured IBM Code Engine project if deploying serverless

Configuration

The app expects several environment variables (set these in your Code Engine project or locally with a .env file):

  • IBM_API_KEY – IBM Cloud API key
  • ACCOUNT_ID – Your IBM Cloud account ID
  • RESOURCE_GROUP_ID – ID of the Resource Group students should see
  • ACCESS_GROUP_ID – Access Group name (For example, QZD35G-student-access I've hardcoded)
  • SITE_TOKEN – Shared secret token to restrict who can call the endpoint

How to run locally

Clone this repo and install dependencies:

pip install -r requirements.txt

Create a .env file with your environment variables:

IBM_API_KEY=your-ibm-api-key
ACCOUNT_ID=your-account-id
RESOURCE_GROUP_ID=your-resource-group-id
ACCESS_GROUP_ID=your-access-group-id
SITE_TOKEN=your-secret-token

Run the app:

python app.py

It will listen on http://localhost:8080.

Test with curl:

curl -X POST http://localhost:8080/invite \
  -H "Content-Type: application/json" \
  -H "X-SITE-TOKEN: <your-site-token>" \
  -d '{"email":"student@example.com"}'

About

A Flask web service that lets students get temporary access to IBM PowerVS. I designed it to be simple and secure. It runs on IBM Code Engine (serverless) and can scale with demand.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published