{Pulumi} S3/AWS

 

https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucket/

 


Python: 3.9.13

-- 1. macにPulumiインストール

brew install pulumi/tap/pulumi

-- 2. macAWS CLIインストール

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

which aws
aws --version


-- 3. Create new project

mkdir test
cd test
pulumi new aws-python


vim __main__.py


import pulumi
import pulumi_aws as aws


bucket123 = aws.s3.BucketV2(
    "bucket123",
    bucket="bucket123",
    force_destroy=True,
    tags={
        "Name": "bucket123",
    } )

bucketpublicaccessblock123 = aws.s3.BucketPublicAccessBlock(
    "bucketpublicaccessblock123",
    bucket=bucket123.id,
    block_public_acls=True,
    block_public_policy=True,
    ignore_public_acls=True,
    restrict_public_buckets=True)

 


-- 4. pulumi 実行

pulumi up


aws s3 ls
echo test > test.txt
aws s3 cp test.txt s3://bucket123
aws s3 ls s3://bucket123 --recursive --human-readable


-- 5. クリーンアップ

pulumi destroy

pulumi stack rm dev