# PhysicalResourceId

Physical ID of the custom resource.

Obtainable from: PhysicalResourceId.fromResponse, PhysicalResourceId.of

- Source: [`custom-resources/lib/aws-custom-resource/aws-custom-resource.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts#L43)

## Example

TypeScript:

```ts
const crossAccountRoleArn = 'arn:aws:iam::OTHERACCOUNT:role/CrossAccountRoleName'; // arn of role deployed in separate account

const callRegion = 'us-west-1'; // sdk call to be made in specified region (optional)

new cr.AwsCustomResource(this, 'CrossAccount', {
  onCreate: {
    assumedRoleArn: crossAccountRoleArn,
    region: callRegion, // optional
    service: 'sts',
    action: 'GetCallerIdentity',
    physicalResourceId: cr.PhysicalResourceId.of('id'),
  },
  policy: cr.AwsCustomResourcePolicy.fromStatements([iam.PolicyStatement.fromJson({
    Effect: "Allow",
    Action: "sts:AssumeRole",
    Resource: crossAccountRoleArn,
  })]),
});
```

Python:

```python
cross_account_role_arn = "arn:aws:iam::OTHERACCOUNT:role/CrossAccountRoleName" # arn of role deployed in separate account

call_region = "us-west-1" # sdk call to be made in specified region (optional)

cr.AwsCustomResource(self, "CrossAccount",
    on_create=cr.AwsSdkCall(
        assumed_role_arn=cross_account_role_arn,
        region=call_region,  # optional
        service="sts",
        action="GetCallerIdentity",
        physical_resource_id=cr.PhysicalResourceId.of("id")
    ),
    policy=cr.AwsCustomResourcePolicy.from_statements([iam.PolicyStatement.from_json({
        "Effect": "Allow",
        "Action": "sts:AssumeRole",
        "Resource": cross_account_role_arn
    })])
)
```

Java:

```java
String crossAccountRoleArn = "arn:aws:iam::OTHERACCOUNT:role/CrossAccountRoleName"; // arn of role deployed in separate account

String callRegion = "us-west-1"; // sdk call to be made in specified region (optional)

 // sdk call to be made in specified region (optional)
AwsCustomResource.Builder.create(this, "CrossAccount")
        .onCreate(AwsSdkCall.builder()
                .assumedRoleArn(crossAccountRoleArn)
                .region(callRegion) // optional
                .service("sts")
                .action("GetCallerIdentity")
                .physicalResourceId(PhysicalResourceId.of("id"))
                .build())
        .policy(AwsCustomResourcePolicy.fromStatements(List.of(PolicyStatement.fromJson(Map.of(
                "Effect", "Allow",
                "Action", "sts:AssumeRole",
                "Resource", crossAccountRoleArn)))))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var crossAccountRoleArn = "arn:aws:iam::OTHERACCOUNT:role/CrossAccountRoleName"; // arn of role deployed in separate account

var callRegion = "us-west-1"; // sdk call to be made in specified region (optional)

 // sdk call to be made in specified region (optional)
new AwsCustomResource(this, "CrossAccount", new AwsCustomResourceProps {
    OnCreate = new AwsSdkCall {
        AssumedRoleArn = crossAccountRoleArn,
        Region = callRegion,  // optional
        Service = "sts",
        Action = "GetCallerIdentity",
        PhysicalResourceId = PhysicalResourceId.Of("id")
    },
    Policy = AwsCustomResourcePolicy.FromStatements(new [] { PolicyStatement.FromJson(new Dictionary<string, string> {
        { "Effect", "Allow" },
        { "Action", "sts:AssumeRole" },
        { "Resource", crossAccountRoleArn }
    }) })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
crossAccountRoleArn := "arn:aws:iam::OTHERACCOUNT:role/CrossAccountRoleName" // arn of role deployed in separate account

callRegion := "us-west-1" // sdk call to be made in specified region (optional)

 // sdk call to be made in specified region (optional)
cr.NewAwsCustomResource(this, jsii.String("CrossAccount"), &AwsCustomResourceProps{
	OnCreate: &AwsSdkCall{
		AssumedRoleArn: crossAccountRoleArn,
		Region: callRegion,
		 // optional
		Service: jsii.String("sts"),
		Action: jsii.String("GetCallerIdentity"),
		PhysicalResourceId: cr.PhysicalResourceId_Of(jsii.String("id")),
	},
	Policy: cr.AwsCustomResourcePolicy_FromStatements([]PolicyStatement{
		iam.PolicyStatement_FromJson(map[string]*string{
			"Effect": jsii.String("Allow"),
			"Action": jsii.String("sts:AssumeRole"),
			"Resource": crossAccountRoleArn,
		}),
	}),
})
```

## Properties

- `id`: string — Literal string to be used as the physical id.

- `responsePath`: string — Path to a response data element to be used as the physical id.

## Methods

- `fromResponse(responsePath: string): PhysicalResourceId // chainable` (static) — Extract the physical resource id from the path (dot notation) to the data in the API call response.

- `of(id: string): PhysicalResourceId // chainable` (static) — Explicit physical resource id.
