
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@ttoss/cloud-roles
Advanced tools
Create CloudFormation templates for IAM roles with TypeScript.
pnpm add @ttoss/cloud-roles
import { createRolesTemplate } from '@ttoss/cloud-roles';
const template = createRolesTemplate({
resources: {
AppSyncLambdaFunctionIAMRole: {
Type: 'AWS::IAM::Role',
Properties: {
AssumeRolePolicyDocument: {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Action: 'sts:AssumeRole',
Principal: { Service: 'lambda.amazonaws.com' },
},
],
},
ManagedPolicyArns: [
'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole',
],
},
},
},
});
export default template;
createRolesTemplateGenerates a CloudFormation template containing one or more AWS::IAM::Role resources and automatically exports each role's ARN as a stack output.
resources: { [key: string]: IAMRoleResource } — map of logical resource IDs to AWS::IAM::Role resource definitions.path?: string — IAM path applied to every role that does not already define Properties.Path. Defaults to IAM_PATH ('/custom-iam/'). IAM (and thus CloudFormation) requires paths to begin and end with / (e.g. '/my-app/'); createRolesTemplate does not validate this, so an invalid path will cause a deploy-time error.resources that has no Properties.Path set will have its Path automatically set to the resolved path value.<LogicalId>Arn is added, exporting the role ARN under the key <StackName>:<LogicalId>Arn.createRolesTemplate mutates the provided resources objects by setting resource.Properties.Path when it is missing. If you need to reuse the same resource definitions elsewhere, clone them before passing them to this function.import { createRolesTemplate } from '@ttoss/cloud-roles';
const template = createRolesTemplate({
path: '/my-app/',
resources: {
/* ... */
},
});
Roles that already declare Properties.Path are left unchanged.
IAM_PATHThe default IAM path constant used when path is not provided:
import { IAM_PATH } from '@ttoss/cloud-roles';
console.log(IAM_PATH); // '/custom-iam/'
iam:PassRole with IAM pathsSetting a dedicated IAM path for application roles enables a simple but effective deployment security boundary.
Pattern:
createRolesTemplate (keeping them under /custom-iam/ or a custom path).iam:PassRole only for roles under that path.This separates privileged IAM management (run infrequently, with elevated permissions) from regular application deployment (run on every release, with limited permissions).
Example deployment policy:
- Effect: Allow
Action:
- iam:PassRole
Resource:
- arn:aws:iam::*:role/custom-iam/*
Condition:
StringEquals:
iam:PassedToService:
- lambda.amazonaws.com
- appsync.amazonaws.com
With this policy, a deployment pipeline can attach centrally managed roles to Lambda functions and AppSync data sources, but cannot create or modify those roles itself.
FAQs
Create CloudFormation templates for roles with TypeScript.
We found that @ttoss/cloud-roles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.