# LayerVersionPermission

Identification of an account (or organization) that is allowed to access a Lambda Layer Version.

- Source: [`aws-lambda/lib/layers.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-lambda/lib/layers.ts#L134)

## Example

```ts
const layer = new lambda.LayerVersion(stack, 'MyLayer', {
  code: lambda.Code.fromAsset(path.join(__dirname, 'layer-code')),
  compatibleRuntimes: [lambda.Runtime.NODEJS_LATEST],
  license: 'Apache-2.0',
  description: 'A layer to test the L2 construct',
});

// To grant usage by other AWS accounts
layer.addPermission('remote-account-grant', { accountId: awsAccountId });

// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });

new lambda.Function(stack, 'MyLayeredLambda', {
  code: new lambda.InlineCode('foo'),
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
  layers: [layer],
});
```

## Properties

- `accountId`: string (required) — The AWS Account id of the account that is authorized to use a Lambda Layer Version.

  The wild-card ``'*'`` can be
  used to grant access to "any" account (or any account in an organization when ``organizationId`` is specified).

- `organizationId`: string — The ID of the AWS Organization to which the grant is restricted.

  Can only be specified if ``accountId`` is ``'*'``
