Skip to content

Commit

Permalink
Merge pull request #50 from nf-core/test-datasets
Browse files Browse the repository at this point in the history
Allow uploading of files
  • Loading branch information
edmundmiller authored Jul 10, 2024
2 parents ae378a2 + adf5adb commit 5feb705
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion pulumi/test-datasets/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pulumi
import pulumi_aws as aws

awsmegatests_bucket = aws.s3.Bucket(
test_datasets_bucket = aws.s3.Bucket(
"test-datasets-bucket",
arn="arn:aws:s3:::nf-core-test-datasets",
bucket="nf-core-test-datasets",
Expand Down Expand Up @@ -36,3 +36,33 @@
),
),
)

# Define the policy which allows users to put objects in the S3 bucket
policy = aws.iam.Policy(
"bucketPutPolicy",
description="Allow users to put objects in the S3 bucket",
policy=test_datasets_bucket.arn.apply(
lambda bucket_arn: f"""{{
"Version": "2012-10-17",
"Statement": [
{{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "{bucket_arn}/*"
}}
]
}}"""
),
)

# List of AWS user names to attach the policy to
usernames = ["edmund", "maxime"]

# Attach the policy to each user
for username in usernames:
aws.iam.UserPolicyAttachment(
f"{username}-putPolicyAttachment", user=username, policy_arn=policy.arn
)

# Export the bucket name
pulumi.export("bucket_name", test_datasets_bucket.bucket)

0 comments on commit 5feb705

Please sign in to comment.