DEV Community

Cover image for Running code against S3 from inside a GUI: how Buckets gates scripts and CLI commands
Aditi Dange
Aditi Dange

Posted on

Running code against S3 from inside a GUI: how Buckets gates scripts and CLI commands

Exploring execution reviews, user-controlled cancellation, and AWS IAM permission enforcement through hands-on Python and AWS CLI workflows.

Generating code for cloud operations is convenient. Executing that code with active AWS credentials is a different responsibility altogether.

A Python script that lists objects in an Amazon S3 bucket is relatively straightforward. Changing a few lines of that script, however, can turn a read-only operation into one that modifies or deletes cloud resources.

The same applies to AWS CLI commands. A simple listing command and a destructive deletion command can be executed from the same terminal, but their consequences are very different.

While testing Buckets by Serverless Creed, I explored how its in-app Python execution and AWS CLI Terminal handle these differences.

My focus was on three questions:

  • Can developers execute read-only S3 operations directly from the application?
  • Can potentially destructive operations be reviewed and cancelled before execution?
  • What happens when a destructive request reaches AWS using credentials that do not have the required permission?

This tutorial walks through the tested workflows and explains the distinction between application-level execution review and AWS-side authorization.

1. Understanding developer execution safety

Buckets provides tools for generating AWS SDK code and executing AWS CLI commands from within its desktop interface.

This reduces the need to switch between the AWS Console, an external terminal, and a separate code editor for common S3 operations.

However, code generation does not make code inherently safe.

A generated script can be edited before execution, and an AWS CLI command can target resources beyond the operation originally intended by the developer.

Three separate controls are important in this context:

Control Purpose
Execution review Displays the proposed code or command and its execution context
User cancellation Allows the user to stop a proposed operation before execution
AWS IAM authorization Determines whether the active AWS principal is permitted to perform the requested AWS operation

These controls complement one another, but they are not interchangeable.

Tested environment

Component Configuration
Application Buckets by Serverless Creed
Python execution test Buckets v2.9.9
AWS CLI execution test Version not explicitly recorded in the scenario documentation
AWS Region us-east-1
SDK AWS SDK for Python (boto3)
AWS profiles Administrative and restricted read-only profiles

Resource names and sensitive identifiers in the screenshots have been anonymized for publication. The observed execution results remain unchanged.

2. Prepare a disposable S3 environment

Before testing execution controls, create an isolated S3 bucket containing a small, non-sensitive text file.

For this tutorial, I will use the following illustrative resource names:

s3-developer-safety-demo/
└── sample.txt
Enter fullscreen mode Exit fullscreen mode

Use a globally unique bucket name when reproducing the workflow.

The original test object was 31 bytes.

I configured two AWS profiles:

  • demo-admin-profile — an administrative profile used to prepare and clean up the test environment.
  • demo-readonly-profile — a restricted IAM profile without permission to delete the test object.

For routine development, prefer narrowly scoped credentials instead of administrative access.

Initial S3 bucket and test object
An isolated S3 bucket containing a disposable object for execution safety testing.

All destructive operations in this tutorial should be tested only against disposable resources that you are authorized to use.


Part 1: Executing Python against Amazon S3

3. Generate and execute a read-only Python script

In Buckets, open Generate S3 Code and select:

  • Language: Python
  • Category: Bucket Operations
  • Operation: List Bucket Objects

Buckets generates a boto3 snippet for the selected operation.

A simplified equivalent of the generated listing operation is:

import boto3

s3 = boto3.client("s3", region_name="us-east-1")

response = s3.list_objects_v2(
    Bucket="s3-developer-safety-demo"
)

for obj in response.get("Contents", []):
    print(obj["Key"], obj["Size"])
Enter fullscreen mode Exit fullscreen mode

The list_objects_v2() operation retrieves object-listing information from the specified S3 bucket. It does not modify the objects.

For larger buckets, pagination is necessary because a single ListObjectsV2 response returns at most 1,000 keys. The single-object test did not require pagination.

Before execution, review the generated source and the active AWS session.

Generated Python code and successful execution
Generated Python code and successful execution
The generated boto3 listing operation executes successfully using the active AWS session.

I executed the read-only snippet and verified that the terminal output listed the expected object.

The important point here is that the script was executed from within Buckets rather than copied into an external Python environment.

4. Modify the generated code and inspect the execution review

The safety considerations change when generated code is edited.

To test this, I modified the listing script to introduce an S3 deletion operation.

The following example illustrates the type of mutation being reviewed:

import boto3

s3 = boto3.client("s3", region_name="us-east-1")

s3.delete_object(
    Bucket="s3-developer-safety-demo",
    Key="sample.txt"
)
Enter fullscreen mode Exit fullscreen mode

Unlike list_objects_v2(), delete_object() requests a change to the remote S3 object state.

The outcome of an authorized deletion depends on the bucket's configuration, including versioning and Object Lock settings.

I selected Execute to open the execution review.

The review displayed the modified source code rather than only describing the original listing operation.

Execution review showing the edited deletion code
The execution review presents the modified Python source before the user approves execution.

This is an important distinction. A script should be reviewed based on the code that is about to run, not simply the operation template from which it was originally generated.

The review also provided execution context and warnings about potential resource access and cost impact.

For arbitrary Python code, however, a review cannot necessarily determine every operation the script might perform at runtime.

5. Cancel the mutation before execution

Instead of approving the modified script, I selected Cancel.

Buckets displayed the following result:

Code execution canceled by the user
Enter fullscreen mode Exit fullscreen mode

Python execution cancellation
The terminal confirms that the proposed Python execution was cancelled by the user.

I subsequently verified that the test object remained available.

In this case, the mutation was prevented by user cancellation at the application review stage.

This was not an AWS IAM denial. The proposed execution was cancelled before the script was allowed to proceed.

The workflow can be summarized as:

Generate read-only code
        |
Edit code to introduce a mutation
        |
Review the modified source
        |
Select Cancel
        |
Execution stopped
Enter fullscreen mode Exit fullscreen mode

The practical value of this review is that it gives developers an opportunity to inspect changes before granting execution approval.

6. Test the same mutation using restricted AWS credentials

Cancellation protects against an operation that the user decides not to execute.

But what happens when the user approves an operation that the active AWS principal is not authorized to perform?

To test this separately, I switched to the restricted read-only AWS profile.

I submitted a Python delete_object() operation targeting the disposable test object.

During the initial edits, I encountered Python syntax and indentation errors. After correcting the code, I reviewed and executed the deletion request.

AWS returned:

AccessDenied
Enter fullscreen mode Exit fullscreen mode

The error indicated that the active principal lacked permission to perform s3:DeleteObject.

I then switched back to the administrative profile, refreshed the bucket, and confirmed that the original 31-byte object was still present.



AWS rejects the deletion request under restricted credentials, and the original object remains present.

This result is particularly important:

Buckets displayed the execution review and allowed the approved request to reach AWS. AWS IAM denied the unauthorized deletion.

Application-level prevention of the mutation before the AWS request was not demonstrated.

The execution review and AWS IAM authorization therefore acted as separate controls.


Part 2: Reviewing AWS CLI commands inside Buckets

7. Execute a read-only AWS CLI command

The AWS CLI provides another way to interact with S3 resources programmatically.

In Buckets, open the in-app AWS CLI Terminal and submit the following listing command:

aws s3 ls s3://s3-developer-safety-demo/
Enter fullscreen mode Exit fullscreen mode

The command lists the objects in the specified bucket.

In my test, the terminal successfully returned the existing text file and its size.

Successful AWS CLI listing
The in-app AWS CLI Terminal successfully lists the disposable S3 test object.

This provides a convenient way to perform common AWS operations without opening a separate terminal window.

8. Review a destructive AWS CLI command

Next, I submitted a command that requests deletion of the test object.

aws s3api delete-object --bucket s3-developer-safety-demo --key sample.txt
Enter fullscreen mode Exit fullscreen mode

Unlike the previous listing command, this operation can change the state of an S3 object.

Before execution, Buckets displayed a command review containing information about:

  • The active AWS principal and Region.
  • The target S3 object.
  • The likely IAM action, s3:DeleteObject.
  • Potential resource impact.
  • The command proposed for execution.

Destructive AWS CLI command review
The execution review identifies the deletion command, target resource, active principal, and likely required permission.

The review gives the developer an opportunity to check whether the intended action matches the actual command.

I selected Cancel rather than approving the deletion.

The terminal reported that the AWS CLI command was cancelled by the user. Refreshing the bucket confirmed that the object remained present.

As with Python execution, cancellation stopped the proposed command at the application review stage.

9. Verify AWS IAM enforcement for CLI commands

I then switched to the restricted read-only AWS profile and submitted the same deletion command.

The review displayed the restricted IAM principal and the target object.

This time, I approved execution specifically to verify AWS permission enforcement.

AWS returned an AccessDenied response indicating that the principal was not authorized to perform s3:DeleteObject.

Refreshing the bucket confirmed that the test object was still present.

CLI AccessDenied response and object verification
The deletion request reaches AWS but is denied because the active IAM principal lacks the required permission.

The outcome matched the Python permission test.

Buckets provided an execution review, but did not independently prevent the approved deletion request from reaching AWS based on the restricted profile.

AWS IAM enforced the permission boundary.

This is why least-privilege credentials remain essential even when an application provides execution confirmation dialogs.

10. Reviewing potentially billable operations

Execution safety is not limited to preventing accidental deletion.

Some AWS commands can provision resources or initiate operations that may incur charges.

To explore this, I submitted a sample AWS Lambda create-function command containing placeholder role and deployment-package values.

The execution review identified:

  • The proposed Lambda function.
  • The likely lambda:CreateFunction permission.
  • Potential resource-creation impact.
  • API request and cost considerations.

Lambda resource-creation and cost-risk review
The command review identifies potential resource creation, required permissions, and cost considerations before execution.

I cancelled the command without running it.

No Lambda function was created during this check.

The purpose was to inspect the review behaviour, not to validate successful Lambda deployment or calculate its actual cost.

This illustrates how execution review can help developers identify operations with potential financial consequences as well as destructive ones.

A cost warning is not a billing estimate or a spending limit. Actual charges depend on the services used, their configuration, and subsequent usage.


11. Comparing the observed results

The following table summarizes the tested execution paths.

Operation Observed outcome Relevant control
Python object listing Successful AWS authorization
Edited Python deletion, cancelled Execution cancelled User cancellation
Python deletion using restricted credentials AccessDenied AWS IAM
AWS CLI object listing Successful AWS authorization
CLI deletion, cancelled Execution cancelled User cancellation
CLI deletion using restricted credentials AccessDenied AWS IAM
Lambda creation command Reviewed and cancelled User cancellation

No unintended S3 object deletion was observed during these execution safety checks.

The test object was subsequently removed intentionally during cleanup.

Where does each control operate?

The execution flow can be understood as:

Python script or AWS CLI command
              |
      Buckets execution review
              |
       User decision
         /         \
      Cancel      Approve
        |            |
      Stop       Execute request
                     |
               AWS authorization
                 /         \
              Allow        Deny
                |            |
          AWS operation   AccessDenied
Enter fullscreen mode Exit fullscreen mode

This is a conceptual representation of the tested workflows, not a complete description of every internal execution path.

The most significant finding is that an execution review does not replace AWS authorization.

A user may approve a command, but AWS can still reject it if the active principal lacks the necessary permission.

Conversely, if the active principal has broad permissions, an approved destructive command may succeed.

12. Security considerations

Use least-privilege AWS credentials

For a developer who only needs to list and read objects from a specific bucket, permissions should be limited to the necessary operations.

The following is an illustrative IAM policy for read-only access to the tutorial bucket:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListDemoBucket",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::s3-developer-safety-demo"
    },
    {
      "Sid": "ReadDemoObjects",
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::s3-developer-safety-demo/*"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This is an illustrative policy, not a reproduction of the exact policy used during my tests.

It does not grant s3:DeleteObject or s3:PutObject.

If no other applicable policy grants those permissions, AWS authorization denies the corresponding requests.

Additional permissions may be required for application discovery workflows or objects encrypted using AWS KMS. Avoid granting broader permissions without understanding why they are needed.

Review the actual code, not just the template

A script generated for a read-only operation can be modified to perform a mutation.

Before approving execution, inspect the source, target resources, active credentials, and Region.

Understand the limits of arbitrary code execution

Python is a general-purpose programming language. Depending on the execution environment, a script may interact with local files, external network services, and cloud resources.

The Python execution review in my test warned that the code runs as a native child process with outbound network access and the desktop user's operating-system permissions.

It also indicated that arbitrary source code can make repeated requests and access resources permitted by the active principal.

Do not interpret the execution review as a complete code sandbox, malware detector, or guarantee that arbitrary code is safe.

Only execute code that you understand and trust.

Verify cloud-side outcomes independently

After cancellation or a denied mutation, refresh the affected resource and verify its state.

For higher-risk production operations, consider independent verification through the AWS Console, a separate authorized CLI session, or appropriate audit logging.

My tests verified the object's continued presence through refreshed bucket listings. I did not perform a cryptographic integrity comparison or independently inspect CloudTrail events for these operations.

13. AWS costs and operational limits

Running Python and AWS CLI commands from a desktop application does not eliminate the underlying AWS service charges.

Potential costs depend on the operations executed.

Operation Potential cost
S3 object listing LIST request charges
S3 object retrieval GET requests, retrieval and applicable transfer charges
S3 object upload PUT requests and storage
S3 object deletion Storage-class-specific early deletion considerations may apply
Lambda execution Invocation and compute charges, if a function is created and invoked
Arbitrary scripts Charges associated with the AWS services and resources accessed

For illustration, at S3 Standard request rates in US East (N. Virginia), 100 LIST requests at $0.005 per 1,000 requests would cost approximately $0.0005, excluding other usage.

Actual request counts and billing were not measured during these tests.

Repeated requests, pagination, retries, and additional service calls can increase usage. An arbitrary script may generate substantially more activity than a single command suggests.

The Lambda command was cancelled before execution, so no Lambda resource was created through that test.

Always consult the relevant AWS pricing documentation before approving resource-creation or potentially expensive operations.

14. Cleanup

After completing the execution safety checks, I:

  • Switched back to the authorized administrative profile.
  • Removed the disposable test object.
  • Deleted the empty S3 test bucket.
  • Verified bucket-list synchronization.
  • Deleted the temporary read-only IAM user.

For your own environment, also remove any temporary access keys, unused saved profiles, or other credentials created specifically for testing.

Do not delete shared IAM identities or production resources as part of tutorial cleanup.

Final thoughts

Executing AWS operations from within a desktop application can make development workflows more convenient, but convenience should not come at the expense of understanding what is being executed.

My testing demonstrated that Buckets provides execution reviews for edited Python code and destructive AWS CLI commands, along with the ability to cancel proposed operations.

It also demonstrated that AWS IAM remains responsible for enforcing the permissions of the active AWS principal when a request reaches AWS.

The distinction matters:

  • Execution review helps developers understand a proposed action.
  • Cancellation stops an operation the user chooses not to approve.
  • AWS IAM enforces the cloud-side authorization boundary.

Application-level blocking of unauthorized mutations before they reach AWS was not demonstrated in these tests.

The broader engineering lesson is that execution safety depends on combining informed user decisions, appropriately scoped credentials, and verification of actual resource state.

A confirmation dialog is a useful safeguard. Least-privilege authorization is still essential.


Validation references

This tutorial is based on hands-on testing conducted during my internship at Serverless Creed:

  • TC-DEVSAFE-001: In-app code execution gates the code actually executed — Buckets v2.9.9.
  • TC-DEVSAFE-002: AWS CLI terminal reviews arbitrary destructive or billable commands.

Further reading

Top comments (0)