# PhysicalResourceIdReference

Reference to the physical resource id that can be passed to the AWS operation as a parameter.

Implements: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html)

- 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#L21)
- Type last changed: v2.79.0 · 10 May 2023

## Example

TypeScript:

```ts
const awsCustom = new cr.AwsCustomResource(this, 'aws-custom', {
  onCreate: {
    service: '...',
    action: '...',
    parameters: {
      text: '...',
    },
    physicalResourceId: cr.PhysicalResourceId.of('...'),
  },
  onUpdate: {
    service: '...',
    action: '...',
    parameters: {
      text: '...',
      resourceId: new cr.PhysicalResourceIdReference(),
    },
  },
  policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
    resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
  }),
})
```

Python:

```python
aws_custom = cr.AwsCustomResource(self, "aws-custom",
    on_create=cr.AwsSdkCall(
        service="...",
        action="...",
        parameters={
            "text": "..."
        },
        physical_resource_id=cr.PhysicalResourceId.of("...")
    ),
    on_update=cr.AwsSdkCall(
        service="...",
        action="...",
        parameters={
            "text": "...",
            "resource_id": cr.PhysicalResourceIdReference()
        }
    ),
    policy=cr.AwsCustomResourcePolicy.from_sdk_calls(
        resources=cr.AwsCustomResourcePolicy.ANY_RESOURCE
    )
)
```

Java:

```java
AwsCustomResource awsCustom = AwsCustomResource.Builder.create(this, "aws-custom")
        .onCreate(AwsSdkCall.builder()
                .service("...")
                .action("...")
                .parameters(Map.of(
                        "text", "..."))
                .physicalResourceId(PhysicalResourceId.of("..."))
                .build())
        .onUpdate(AwsSdkCall.builder()
                .service("...")
                .action("...")
                .parameters(Map.of(
                        "text", "...",
                        "resourceId", new PhysicalResourceIdReference()))
                .build())
        .policy(AwsCustomResourcePolicy.fromSdkCalls(SdkCallsPolicyOptions.builder()
                .resources(AwsCustomResourcePolicy.ANY_RESOURCE)
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var awsCustom = new AwsCustomResource(this, "aws-custom", new AwsCustomResourceProps {
    OnCreate = new AwsSdkCall {
        Service = "...",
        Action = "...",
        Parameters = new Dictionary<string, string> {
            { "text", "..." }
        },
        PhysicalResourceId = PhysicalResourceId.Of("...")
    },
    OnUpdate = new AwsSdkCall {
        Service = "...",
        Action = "...",
        Parameters = new Dictionary<string, object> {
            { "text", "..." },
            { "resourceId", new PhysicalResourceIdReference() }
        }
    },
    Policy = AwsCustomResourcePolicy.FromSdkCalls(new SdkCallsPolicyOptions {
        Resources = AwsCustomResourcePolicy.ANY_RESOURCE
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
awsCustom := cr.NewAwsCustomResource(this, jsii.String("aws-custom"), &AwsCustomResourceProps{
	OnCreate: &AwsSdkCall{
		Service: jsii.String("..."),
		Action: jsii.String("..."),
		Parameters: map[string]*string{
			"text": jsii.String("..."),
		},
		PhysicalResourceId: cr.PhysicalResourceId_Of(jsii.String("...")),
	},
	OnUpdate: &AwsSdkCall{
		Service: jsii.String("..."),
		Action: jsii.String("..."),
		Parameters: map[string]interface{}{
			"text": jsii.String("..."),
			"resourceId": cr.NewPhysicalResourceIdReference(),
		},
	},
	Policy: cr.AwsCustomResourcePolicy_FromSdkCalls(&SdkCallsPolicyOptions{
		Resources: cr.AwsCustomResourcePolicy_ANY_RESOURCE(),
	}),
})
```

## Initializer

TypeScript:

```ts
new PhysicalResourceIdReference()
```

Python:

```python
PhysicalResourceIdReference()
```

Java:

```java
new PhysicalResourceIdReference()
```

C# / .NET:

```csharp
new PhysicalResourceIdReference()
```

Golang:

```go
NewPhysicalResourceIdReference()
```

## Properties

- `creationStack`: string[] — The creation stack of this resolvable which will be appended to errors thrown during resolution.

  This may return an array with a single informational element indicating how
  to get this property populated, if it was skipped for performance reasons.

## Methods

- `resolve(_context: IResolveContext): any` — Produce the Token's value at resolution time.

- `toJSON(): string` — toJSON serialization to replace `PhysicalResourceIdReference` with a magic string.

- `toString(): string` — Return a string representation of this resolvable object.

  Returns a reversible string representation.
