I am attempting to upload a file to a S3 bucket created using CDK, however i am consistently running into the same error even using the example code provided by AWS.
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
provides the following error inside visual studio code and when running npm build
Property 'env' is missing in type 'Bucket' but required in type 'IBucket'.
From what i can tell the env relates to the resource environment described here: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.ResourceEnvironment.html
I cannot figure out how to provide this to the bucket object as it doesn't seem to appear on the available input props described here: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.Bucket.html
Any help would be greatly appreciated.