# AddToResourcePolicyResult

Result of calling addToResourcePolicy.

Returned by: [IBucket.addToResourcePolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html#addtoresourcepolicy), [IChannel.addToResourcePolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-mediapackagev2-alpha.IChannel.html#addtoresourcepolicy), IKey.addToResourcePolicy, IOriginEndpoint.addToResourcePolicy, IQueue.addToResourcePolicy, IRepository.addToResourcePolicy, IResourceWithPolicyV2.addToResourcePolicy, ISecret.addToResourcePolicy, IStream.addToResourcePolicy, IStreamConsumer.addToResourcePolicy, ITable.addToResourcePolicy, ITableBucket.addToResourcePolicy, ITopic.addToResourcePolicy, TableV2.addToStreamResourcePolicy, TableV2MultiAccountReplica.addToStreamResourcePolicy

- Source: [`aws-iam/lib/grant.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-iam/lib/grant.ts#L601)

## Example

TypeScript:

```ts
const bucket = s3.Bucket.fromBucketName(this, 'existingBucket', 'amzn-s3-demo-bucket');

// No policy statement will be added to the resource
const result = bucket.addToResourcePolicy(
  new iam.PolicyStatement({
    actions: ['s3:GetObject'],
    resources: [bucket.arnForObjects('file.txt')],
    principals: [new iam.AccountRootPrincipal()],
  })
);
```

Python:

```python
bucket = s3.Bucket.from_bucket_name(self, "existingBucket", "amzn-s3-demo-bucket")

# No policy statement will be added to the resource
result = bucket.add_to_resource_policy(
    iam.PolicyStatement(
        actions=["s3:GetObject"],
        resources=[bucket.arn_for_objects("file.txt")],
        principals=[iam.AccountRootPrincipal()]
    ))
```

Java:

```java
IBucket bucket = Bucket.fromBucketName(this, "existingBucket", "amzn-s3-demo-bucket");

// No policy statement will be added to the resource
AddToResourcePolicyResult result = bucket.addToResourcePolicy(
PolicyStatement.Builder.create()
        .actions(List.of("s3:GetObject"))
        .resources(List.of(bucket.arnForObjects("file.txt")))
        .principals(List.of(new AccountRootPrincipal()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var bucket = Bucket.FromBucketName(this, "existingBucket", "amzn-s3-demo-bucket");

// No policy statement will be added to the resource
var result = bucket.AddToResourcePolicy(
new PolicyStatement(new PolicyStatementProps {
    Actions = new [] { "s3:GetObject" },
    Resources = new [] { bucket.ArnForObjects("file.txt") },
    Principals = new [] { new AccountRootPrincipal() }
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
bucket := s3.Bucket_FromBucketName(this, jsii.String("existingBucket"), jsii.String("amzn-s3-demo-bucket"))

// No policy statement will be added to the resource
result := bucket.AddToResourcePolicy(
iam.NewPolicyStatement(&PolicyStatementProps{
	Actions: []*string{
		jsii.String("s3:GetObject"),
	},
	Resources: []*string{
		bucket.ArnForObjects(jsii.String("file.txt")),
	},
	Principals: []IPrincipal{
		iam.NewAccountRootPrincipal(),
	},
}))
```

## Properties

- `policyDependable`: [IDependable](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IDependable.html) — Dependable which allows depending on the policy change being applied.

  **Default:** If `statementAdded` is true, the resource object itself. Otherwise, no dependable.

- `statementAdded`: boolean (required) — Whether the statement was added.
