Amazon Elastic Compute Cloud

2023/09/12 - Amazon Elastic Compute Cloud - 3 new api methods

Changes  This release adds support for restricting public sharing of AMIs through AMI Block Public Access

EnableImageBlockPublicAccess (new) Link ¶

Enables block public access for AMIs at the account level in the specified Amazon Web Services Region. This prevents the public sharing of your AMIs. However, if you already have public AMIs, they will remain publicly available.

The API can take up to 10 minutes to configure this setting. During this time, if you run GetImageBlockPublicAccessState , the response will be unblocked . When the API has completed the configuration, the response will be block-new-sharing .

For more information, see Block public access to your AMIs in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

client.enable_image_block_public_access(
    ImageBlockPublicAccessState='block-new-sharing',
    DryRun=True|False
)
type ImageBlockPublicAccessState

string

param ImageBlockPublicAccessState

[REQUIRED]

Specify block-new-sharing to enable block public access for AMIs at the account level in the specified Region. This will block any attempt to publicly share your AMIs in the specified Region.

type DryRun

boolean

param DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation . Otherwise, it is UnauthorizedOperation .

rtype

dict

returns

Response Syntax

{
    'ImageBlockPublicAccessState': 'block-new-sharing'
}

Response Structure

  • (dict) --

    • ImageBlockPublicAccessState (string) --

      Returns block-new-sharing if the request succeeds; otherwise, it returns an error.

DisableImageBlockPublicAccess (new) Link ¶

Disables block public access for AMIs at the account level in the specified Amazon Web Services Region. This removes the block public access restriction from your account. With the restriction removed, you can publicly share your AMIs in the specified Amazon Web Services Region.

The API can take up to 10 minutes to configure this setting. During this time, if you run GetImageBlockPublicAccessState , the response will be block-new-sharing . When the API has completed the configuration, the response will be unblocked .

For more information, see Block public access to your AMIs in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

client.disable_image_block_public_access(
    DryRun=True|False
)
type DryRun

boolean

param DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation . Otherwise, it is UnauthorizedOperation .

rtype

dict

returns

Response Syntax

{
    'ImageBlockPublicAccessState': 'unblocked'
}

Response Structure

  • (dict) --

    • ImageBlockPublicAccessState (string) --

      Returns unblocked if the request succeeds; otherwise, it returns an error.

GetImageBlockPublicAccessState (new) Link ¶

Gets the current state of block public access for AMIs at the account level in the specified Amazon Web Services Region.

For more information, see Block public access to your AMIs in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

client.get_image_block_public_access_state(
    DryRun=True|False
)
type DryRun

boolean

param DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation . Otherwise, it is UnauthorizedOperation .

rtype

dict

returns

Response Syntax

{
    'ImageBlockPublicAccessState': 'string'
}

Response Structure

  • (dict) --

    • ImageBlockPublicAccessState (string) --

      The current state of block public access for AMIs at the account level in the specified Amazon Web Services Region.

      Possible values:

      • block-new-sharing - Any attempt to publicly share your AMIs in the specified Region is blocked.

      • unblocked - Your AMIs in the specified Region can be publicly shared.