Skip to content

Instantly share code, notes, and snippets.

@JoshM1994
Created March 20, 2022 02:39
Show Gist options
  • Save JoshM1994/ed9a41bb0c821d8e2be058599dff57a4 to your computer and use it in GitHub Desktop.
Save JoshM1994/ed9a41bb0c821d8e2be058599dff57a4 to your computer and use it in GitHub Desktop.
const accessIdentity = new OriginAccessIdentity(this, 'CloudfrontAccess');
const cloudfrontUserAccessPolicy = new PolicyStatement();
cloudfrontUserAccessPolicy.addActions('s3:GetObject');
cloudfrontUserAccessPolicy.addPrincipals(accessIdentity.grantPrincipal);
cloudfrontUserAccessPolicy.addResources(siteBucket.arnForObjects('*'));
siteBucket.addToResourcePolicy(cloudfrontUserAccessPolicy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment