-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add download step from csds #4
Conversation
Co-authored-by: Evan Sosenko <[email protected]>
Co-authored-by: Evan Sosenko <[email protected]>
Co-authored-by: Evan Sosenko <[email protected]>
Co-authored-by: Evan Sosenko <[email protected]>
Co-authored-by: Evan Sosenko <[email protected]>
@billfreeman44 There are not tested, but should be all we need to setup a basic bucket config. days_to_keep_data_on_s3 = 30
account_id = boto3.client("sts").get_caller_identity().get("Account")
bucket_name = "-".join([account_id, "pureskillgg", "dataset"])
bucket_region = boto3.session.Session().region_name
client = boto3.client("s3")
client.create_bucket(
Bucket=bucket_name,
ACL="private",
CreateBucketConfiguration={"LocationConstraint": bucket_region},
)
client.put_bucket_policy(
Bucket=bucket_name,
Policy=json.dumps(
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"Service": "dataexchange.amazonaws.com"},
"Action": ["s3:PutObject", "s3:PutObjectAcl"],
"Resource": f"arn:aws:s3:::{bucket_name}/*",
"Condition": {"StringEquals": {"aws:SourceAccount": account_id}},
}
],
}
),
)
client.put_bucket_lifecycle_configuration(
Bucket=bucket_name,
LifecycleConfiguration={
"Rules": [
{
"Expiration": {
"Days": days_to_keep_data_on_s3,
},
"Status": "Enabled",
},
],
},
) |
We should add a check at the top of the cell incase the bucket exists. There are three cases for this call client.head_bucket(
Bucket='string',
ExpectedBucketOwner=account_id
)
|
Should be good to go @razor-x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll check it one more time after these updates, but I have to head off for now. I recommend batching the suggestions instead of single commits!
Co-authored-by: Evan Sosenko <[email protected]>
No description provided.