# ArnFormat

An enum representing the various ARN formats that different services use.

Used as argument in: [Arn.split](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Arn.html#split), [Stack.splitArn](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html#splitarn)

- Source: [`core/lib/arn.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/arn.ts#L11)

## Example

TypeScript:

```ts
declare const stack: Stack;

// Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
stack.formatArn({
  service: 'lambda',
  resource: 'function',
  arnFormat: ArnFormat.COLON_RESOURCE_NAME,
  resourceName: 'MyFunction'
});
```

Python:

```python
# stack: Stack

# Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
stack.format_arn(
    service="lambda",
    resource="function",
    arn_format=ArnFormat.COLON_RESOURCE_NAME,
    resource_name="MyFunction"
)
```

Java:

```java
Stack stack;

// Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
stack.formatArn(ArnComponents.builder()
        .service("lambda")
        .resource("function")
        .arnFormat(ArnFormat.COLON_RESOURCE_NAME)
        .resourceName("MyFunction")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Stack stack;

// Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
stack.FormatArn(new ArnComponents {
    Service = "lambda",
    Resource = "function",
    ArnFormat = ArnFormat.COLON_RESOURCE_NAME,
    ResourceName = "MyFunction"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var stack Stack

// Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
stack.FormatArn(&ArnComponents{
	Service: jsii.String("lambda"),
	Resource: jsii.String("function"),
	ArnFormat: awscdk.ArnFormat_COLON_RESOURCE_NAME,
	ResourceName: jsii.String("MyFunction"),
})
```

## Members

| Member | Description |
| --- | --- |
| `NO_RESOURCE_NAME` | This represents a format where there is no 'resourceName' part. |
| `COLON_RESOURCE_NAME` | This represents a format where the 'resource' and 'resourceName' parts are separated with a colon. |
| `SLASH_RESOURCE_NAME` | This represents a format where the 'resource' and 'resourceName' parts are separated with a slash. |
| `SLASH_RESOURCE_SLASH_RESOURCE_NAME` | This represents a format where the 'resource' and 'resourceName' parts are separated with a slash, but there is also an additional slash after the colon separating 'account' from 'resource'. |

## Referenced by

- [`ArnComponents`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.ArnComponents.html).arnFormat
