I've been trying to upload a file to an S3 bucket created using CDK, but I keep encountering the same error even when using AWS's example code.
Here is the stack:
export class TestStack extends cdk.Stack {
public readonly response: string;
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const websiteBucket = new s3.Bucket(this, 'WebsiteBucket', {
websiteIndexDocument: 'index.html',
publicReadAccess: true,
});
new s3deploy.BucketDeployment(this, 'DeployWebsite', {
sources: [s3deploy.Source.asset('./website-dist')],
destinationBucket: websiteBucket,
destinationKeyPrefix: 'web/static' // optional prefix in destination bucket
});
}
}
Here is the main bin as requested:
const app = new cdk.App();
new TestStack(app, "TestStack", {
env: {
account: '123456789',
region: 'us-east-1',
}
});
The destinationBucket
throws the following error in Visual Studio Code and when running npm build:
Property 'env' is missing in type 'Bucket' but required in type 'IBucket'.
As far as I can tell, the env corresponds to the resource environment described here: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.ResourceEnvironment.html
I'm struggling to figure out how to provide this to the bucket object as it doesn't seem to be among the available input props described here: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.Bucket.html
Any assistance would be highly appreciated.