AWS S3: role permissions and trust
An S3 integration uses an AWS IAM role. The role’s permission policy says what it may access; its trust policy says who may assume it.
Understand the idea
Choose a dedicated learning bucket and incoming/ prefix containing only the sample orders.csv. The AWS administrator creates a role using the official bootstrap procedure, then attaches the scoped read policy shown below. Bucket permissions apply to the bucket ARN; object permissions apply to object ARNs.
| Concept | What it means |
|---|---|
| Permission policy | Allow only required bucket and object actions. |
| Role ARN | Identifies the AWS role configured in the integration. |
| Trust policy | Allows Snowflake’s returned identity to assume that role. |
| External ID | An additional condition checked during role assumption. |
A concrete example
Attach this template to the dedicated IAM role after replacing the bucket. It permits listing and reading incoming objects, not uploads or deletion. Configure policies in AWS, not the SQL editor.
Remember: Trust permits assumption; the permission policy limits actions after assumption.
Explain it step by step · full theory
Understand the idea
Choose a dedicated learning bucket and incoming/ prefix containing only the sample orders.csv. The AWS administrator creates a role using the official bootstrap procedure, then attaches the scoped read policy shown below. Bucket permissions apply to the bucket ARN; object permissions apply to object ARNs.
Create the Snowflake integration with that role ARN, then run DESC. Copy the returned STORAGE_AWS_IAM_USER_ARN and STORAGE_AWS_EXTERNAL_ID into the role trust policy. Do not invent either value. The administrator replaces the bootstrap trust relationship with the final trusted identity and external-ID condition.
Follow the workflow
An encrypted bucket may also require approved KMS access and a compatible key policy. Role permissions can still be restricted by bucket policies, organization controls or network rules. Keep these boundaries separate when diagnosing AccessDenied.
After trust is configured, create the external stage in the lab lesson. Integration creation alone does not prove S3 access. Avoid CREATE OR REPLACE on an in-use integration: identity-related configuration and stage dependencies must be reviewed deliberately.
Words used in this lesson
- Permission policy
- Allow only required bucket and object actions.
- Role ARN
- Identifies the AWS role configured in the integration.
- Trust policy
- Allows Snowflake’s returned identity to assume that role.
- External ID
- An additional condition checked during role assumption.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
AWS S3: role permissions and trust
Locate the data
An S3 integration uses an AWS IAM role. The role’s permission policy says what it may access; its trust policy says who may assume it.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Locate the data
An S3 integration uses an AWS IAM role. The role’s permission policy says what it may access; its trust policy says who may assume it.
- Configure the boundary
Choose a dedicated learning bucket and incoming/ prefix containing only the sample orders.csv. The AWS administrator creates a role using the official bootstrap procedure, then attaches the scoped read policy shown below. Bucket permissions apply to the bucket ARN; object permissions apply to object ARNs.
- Observe the outcome
Trust permits assumption; the permission policy limits actions after assumption.
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Shared orders.csv and internal-stage setup
Four orders, one CSV contract
Every CSV lesson uses this fictional orders.csv. One data record represents one order. The first line is a header; the four remaining lines are data. All amounts use the same fictional currency.
order_id,customer_name,amount,order_date
101,"Asha, Rao",120.50,2025-01-01
102,Ben,,2025-01-02
103,Cara,NULL,2025-01-03
104,Dev,0,2025-01-04Notice the comma inside Asha’s quoted name, Ben’s empty amount, Cara’s literal NULL marker and Dev’s zero. We will follow these exact values from file bytes to parsed fields.
Setup order for optional manual practice
- Select an authorized sandbox database and schema. Keep this context consistent across your client sessions.
- Create orders_csv_v1 using lesson 3, then orders_stage using lesson 5. Use fresh sandbox names; do not replace existing shared objects.
- Save the text above as a UTF-8 file named orders.csv. Upload it with a supported local client or the named-stage upload interface.
- Keep only this sample file under the incoming/ prefix when following the four-row expected results.
- Select an authorized warehouse for the staged SELECT examples. File previews use compute; this website runs no SQL.
The examples assume the required role privileges described in the lessons. The external-stage and JSON examples have their own additional setup and are clearly marked.
Before running this lesson
Manual learning examples, not executed here. Use L2_OBJECTS_LAB.SALES from Module 03 and an authorized warehouse for previews. Run shared format/stage setup once. Cloud examples are templates: replace every <placeholder>, use approved cloud resources, and follow the provider setup before running SQL. No credentials belong in this website.
AWS role read policy — replace the bucket name
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::<lab-bucket>"
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::<lab-bucket>",
"Condition": {
"StringLike": {
"s3:prefix": [
"incoming/",
"incoming/*"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion"
],
"Resource": "arn:aws:s3:::<lab-bucket>/incoming/*"
}
]
}What to expect and why
Attach this template to the dedicated IAM role after replacing the bucket. It permits listing and reading incoming objects, not uploads or deletion. Configure policies in AWS, not the SQL editor.
Create the S3 integration
CREATE STORAGE INTEGRATION m5_s3_read
TYPE=EXTERNAL_STAGE STORAGE_PROVIDER=S3 ENABLED=TRUE
STORAGE_AWS_ROLE_ARN='arn:aws:iam::<aws-account-id>:role/<lab-role>'
STORAGE_ALLOWED_LOCATIONS=('s3://<lab-bucket>/incoming/')
STORAGE_BLOCKED_LOCATIONS=('s3://<lab-bucket>/incoming/private/');
DESC INTEGRATION m5_s3_read;What to expect and why
Record the returned IAM user ARN and external ID. The integration exists, but the final AWS trust must still be configured.
AWS role trust — use the DESC values
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "<STORAGE_AWS_IAM_USER_ARN from DESC>"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "<STORAGE_AWS_EXTERNAL_ID from DESC>"
}
}
}
]
}What to expect and why
Apply to the role trust relationship. The identity and external ID must exactly match the integration output; this is separate from the role’s read permissions.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Why are two different resource ARN shapes used in the read policy?
Compare your reasoning
Listing and bucket-location checks target the bucket. GetObject targets objects under incoming/. A bucket ARN alone is not an object-level read grant.
Official sources and curriculum
Module 05 · See module scope