A VPC endpoint policy is an IAM resource policy attached to the endpoint. It controls which principals, actions and resources can be reached through that endpoint. It does not replace IAM or bucket policies – a request must be allowed by all of them. The default policy allows full access.
In this section you restrict s3-interface-endpoint so that clients coming from on-premises can only reach one approved bucket. Gateway endpoint policies work exactly the same way.
-2.


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowOnlyBucket2",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::<your-bucket-name>-2",
"arn:aws:s3:::<your-bucket-name>-2/*"
]
}
]
}

In the Test-Interface-Endpoint session run:
aws s3 cp testfile2.xyz s3://<your-bucket-name>-2 --region <your-region>
aws s3 ls s3://<your-bucket-name>-2 --region <your-region>
aws s3 ls s3://<your-bucket-name> --region <your-region>
Endpoint policy changes can take a minute or two to take effect. If the last command still succeeds, wait a moment and run it again.
AmazonS3FullAccess.