AddToResourcePolicyResult Struct
Result of calling addToResourcePolicy.
| Source | aws-iam/lib/grant.ts |
|---|
Example
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
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
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());
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() }
}));
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
policyDependableoptionalIDependablepolicy_dependableoptionalIDependablepolicyDependableoptionalIDependablePolicyDependableoptionalIDependablePolicyDependableoptionalIDependable #Dependable which allows depending on the policy change being applied.
Default: If statementAdded is true, the resource object itself. Otherwise, no dependable.
statementAddedbooleanstatement_addedboolstatementAddedBooleanStatementAddedboolStatementAdded*bool required #Whether the statement was added.