SnapshotBlockPublicAccess ​
The SnapshotBlockPublicAccess resource allows you to control the public access settings for Amazon EC2 snapshots. By configuring this resource, you can ensure that your snapshots are not publicly accessible, thereby enhancing your security posture. For more details, refer to the AWS EC2 SnapshotBlockPublicAccess documentation.
Minimal Example ​
Create a basic SnapshotBlockPublicAccess resource with the required state property set to "enabled".
import AWS from "alchemy/aws/control";
const snapshotBlockPublicAccess = await AWS.EC2.SnapshotBlockPublicAccess("blockPublicAccess", {
State: "enabled",
adopt: false // By default, set to false to not adopt existing resources.
});
Advanced Configuration ​
You can adopt an existing SnapshotBlockPublicAccess if it already exists by setting the adopt
property to true
.
const adoptedSnapshotBlockPublicAccess = await AWS.EC2.SnapshotBlockPublicAccess("adoptBlockPublicAccess", {
State: "enabled",
adopt: true // This will adopt the existing resource.
});
Customizing State ​
You can also disable public access by setting the state to "disabled".
const snapshotBlockPublicAccessDisabled = await AWS.EC2.SnapshotBlockPublicAccess("disablePublicAccess", {
State: "disabled"
});
Checking Resource Details ​
After creating the SnapshotBlockPublicAccess resource, you can access additional properties such as ARN, creation time, and last update time.
const snapshotBlockPublicAccessDetails = await AWS.EC2.SnapshotBlockPublicAccess("detailsBlockPublicAccess", {
State: "enabled"
});
// Accessing additional properties
console.log(snapshotBlockPublicAccessDetails.Arn);
console.log(snapshotBlockPublicAccessDetails.CreationTime);
console.log(snapshotBlockPublicAccessDetails.LastUpdateTime);