Skip to content
v2.277.0

IamResource Class ​

A class used to generate resource arns for AppSync.

Example ​

ts
const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
declare const api: appsync.IGraphqlApi;

api.grant(role, appsync.IamResource.custom('types/Mutation/fields/updateExample'), 'appsync:GraphQL');
python
# api: appsync.IGraphqlApi
role = iam.Role(self, "Role",
    assumed_by=iam.ServicePrincipal("lambda.amazonaws.com")
)

api.grant(role, appsync.IamResource.custom("types/Mutation/fields/updateExample"), "appsync:GraphQL")
java
IGraphqlApi api;
Role role = Role.Builder.create(this, "Role")
        .assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
        .build();

api.grant(role, IamResource.custom("types/Mutation/fields/updateExample"), "appsync:GraphQL");
csharp
// Install: dotnet add package Amazon.CDK.Lib
IGraphqlApi api;
var role = new Role(this, "Role", new RoleProps {
    AssumedBy = new ServicePrincipal("lambda.amazonaws.com")
});

api.Grant(role, IamResource.Custom("types/Mutation/fields/updateExample"), "appsync:GraphQL");
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var api IGraphqlApi
role := iam.NewRole(this, jsii.String("Role"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("lambda.amazonaws.com")),
})

api.Grant(role, appsync.IamResource_Custom(jsii.String("types/Mutation/fields/updateExample")), jsii.String("appsync:GraphQL"))

Methods ​

all(): IamResource // chainable@staticmethod def all() -> IamResourcepublic static IamResource all()public static IamResource All()func All() IamResourcestatic#
Generate the resource names that accepts all types: `*`.
custom(...arns: string[]): IamResource // chainable@staticmethod def custom(arns: str) -> IamResourcepublic static IamResource custom(String arns)public static IamResource Custom(string arns)func Custom(Arns *string) IamResourcestatic#
Generate the resource names given custom arns.
1 parameter

Parameters

  • arnsarnsarnsarnsArns — The custom arns that need to be permissioned.
ofType(type: string, ...fields: string[]): IamResource // chainable@staticmethod def of_type(type: str, fields: str) -> IamResourcepublic static IamResource ofType(String type, String fields)public static IamResource OfType(string type, string fields)func OfType(Type *string, Fields *string) IamResourcestatic#
Generate the resource names given a type and fields.
2 parameters

Parameters

  • typetypetypetypeType — The type that needs to be allowed.
  • fieldsfieldsfieldsfieldsFields — The fields that need to be allowed, if empty grant permissions to ALL fields.
resourceArns(api: GraphqlApiBase): string[]def resource_arns(self, api: GraphqlApiBase) -> typing.List[str]public List<String> resourceArns(GraphqlApiBase api)public string[] ResourceArns(GraphqlApiBase api)func ResourceArns(Api GraphqlApiBase) *[]*string#
Return the Resource ARN.
1 parameter

Parameters

  • apiapiapiapiApi — The GraphQL API to give permissions.