Let me provide a comprehensive solution addressing all three aspects of your challenge.
IAM Access Group Policy Syntax:
Your policy structure is correct for granting access, but MFA enforcement isn’t configured within IAM policies themselves. Policies define what resources users can access and what actions they can perform, not how they authenticate. The policy you’ve shown grants Manager role access but doesn’t include authentication requirements.
MFA Enforcement for API Access:
MFA in IBM Cloud applies to user logins (console/CLI), not to API keys or service IDs used for programmatic access. This is by design - automated systems can’t perform interactive MFA challenges. For your sensitive APIs, implement Context-Based Restrictions (CBR):
{
"resources": [{"attributes": [{"name": "serviceName", "value": "your-service"}]}],
"contexts": [{"attributes": [{"name": "networkZoneId", "value": "your-zone-id"}]}]
}
CBR rules restrict API access based on network zones (IP ranges), ensuring API calls only come from trusted locations.
Policy Propagation Between Environments:
For consistent enforcement across dev, staging, and production:
- Use Terraform or IBM Cloud Schematics to define IAM policies as code
- Implement identical CBR rules in each environment
- For API keys, use separate service IDs per environment with minimal scopes
- Enable Activity Tracker in all environments to audit policy compliance
Best practice: Replace long-lived API keys with trusted profiles for compute resources. Trusted profiles generate short-lived tokens automatically, eliminating the need for stored credentials. Configure them to assume specific IAM roles, giving you the security benefits of temporary credentials.
For true MFA on sensitive operations, consider implementing application-level authentication with IBM App ID, which supports MFA flows even for API calls through OAuth/OIDC tokens. This gives you programmatic MFA where IBMs IAM doesn’t apply.
Verify your setup: Check Activity Tracker logs for authentication events, review your CBR rules are active, and audit which service IDs have access to sensitive APIs. Rotate all API keys and implement a 90-day rotation policy.