Skip to content
v2.278.0

PhysicalResourceId Class ​

Physical ID of the custom resource.

Example ​

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
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
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();
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 }
    }) })
});
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 ​

idmay be undefinedstringidmay be undefinedstridmay be undefinedStringIdmay be undefinedstringIdmay be undefined*string #
Literal string to be used as the physical id.
responsePathmay be undefinedstringresponse_pathmay be undefinedstrresponsePathmay be undefinedStringResponsePathmay be undefinedstringResponsePathmay be undefined*string #
Path to a response data element to be used as the physical id.

Methods ​

fromResponse(responsePath: string): PhysicalResourceId // chainable@staticmethod def from_response(response_path: str) -> PhysicalResourceIdpublic static PhysicalResourceId fromResponse(String responsePath)public static PhysicalResourceId FromResponse(string responsePath)func FromResponse(ResponsePath *string) PhysicalResourceId static #
Extract the physical resource id from the path (dot notation) to the data in the API call response.
of(id: string): PhysicalResourceId // chainable@staticmethod def of(id: str) -> PhysicalResourceIdpublic static PhysicalResourceId of(String id)public static PhysicalResourceId Of(string id)func Of(Id *string) PhysicalResourceId static #
Explicit physical resource id.