I can't for the life of me get an aws s3 directory...
# aws
b
I can't for the life of me get an aws s3 directory bucket to deploy, keeps saying invalid bucket name, I don't see anything in issues.. and pretty sure I'm doing this right!
Copy code
const azs = aws.getAvailabilityZones(
        {
            state: "available",
        },
        { provider: eastProvider }
    );

    const local_bucket = new aws.s3.DirectoryBucket(
        `${prefix_short}-edge`,
        {
            bucket: azs.then((zones) => {
                console.log(zones);
                const azId = zones.zoneIds.sort()[0];
                return `${config.token}edge--${azId}--x-s3`;
            }),
            location: {
                name: azs.then((zones) => {
                    const azId = zones.zoneIds.sort()[0];
                    return azId;
                }),
            },
        },
        { provider: eastProvider }
    );
spits out:
Copy code
{                                                                                                                                                                   
  groupNames: [ 'us-east-1-zg-1' ],                                                                                                                                 
  id: 'us-east-1',                                                                                                                                                  
  names: [                                                                                                                                                          
    'us-east-1a',                                                                                                                                                   
    'us-east-1b',                                                                                                                                                   
    'us-east-1c',                                                                                                                                                   
    'us-east-1d',                                                                                                                                                   
    'us-east-1e',                                                                                                                                                   
    'us-east-1f'                                                                                                                                                    
  ],                                                                                                                                                                
  state: 'available',                                                                                                                                               
  zoneIds: [                                                                                                                                                        
    'use1-az4',                                                                                                                                                     
    'use1-az6',                                                                                                                                                     
    'use1-az1',                                                                                                                                                     
    'use1-az2',                                                                                                                                                     
    'use1-az3',                                                                                                                                                     
    'use1-az5'                                                                                                                                                      
  ]                                                                                                                                                                 
}
and then:
Copy code
error: creating S3 Directory Bucket (mytokenedge--use1-az1--x-s3): operation error S3:
 CreateBucket, https response error StatusCode: 400, RequestID: 01D73FFA430101953EA43BDD0500C672D76D9270, HostID: hO8ojfFsqHWTYWs, api error InvalidBucketName: The 
specified bucket is not valid.
"@pulumi/aws": "6.68.0",
interesting that when I try to create the bucket by same name in the UI, I don't see all those zones listed in the API output:
l
That seems to match requirements. Could it be an existing bucket? The uniqueness constraint does apply to directory buckets.
b
no, it's not an existing bucket. it appears the confusion is that the getAvailabilityZones() returns all zones, but only some are used in the s3 express bucket. My code was pulling them, and sorting, using az1, but that isn't a valid zone for s3express buckets, for me at least, not sure if that's the same for everyone
l
Ah, so picking a valid zone fixed it? That's not a helpful error message, is it?
b
yes, just changing the code to not ask for zones, and hardcoding to use1-az4 worked
i did a bit of checking didn't see any easy way to determine which zones qualify for s3express out of the set of all zones
but I already went a different direction 😂
i was trying to setup a static site that used lambda at edge for protecting portions of site with basic auth. I then wanted my codebuild project to upload a json file of valid users, since it's part of the site config, but it became a chore because if you update the lambda, you have to update the distribution, env vars dont work on lambda @ edge, and it seems to have very limited s3 access, which it does seem to have in theory, but i couldn't get it to work. last desperate attempt was to use this s3express bucket in the east-1 zone.. then i find that s3express is a whole new thing, new IAM, bucket policies needed.. all kinds of weird stuff, i gave up
l
Ouch. Blog post incoming...