aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.7k stars 3.93k forks source link

(aws-s3-deployment): Typescript error for `destinationBucket` #17977

Closed jolo-dev closed 2 years ago

jolo-dev commented 2 years ago

What is the problem?

Typescript is yelling at me because Property 'transferAccelerationUrlForObject' is missing in type 'Bucket' but required in type 'IBucket'.ts(2741) when setting a Bucket in the destinationBucket- property.

Reproduction Steps

Basically, I followed the instructions from the docs: https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-deployment-readme.html

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
});

What did you expect to happen?

No errors.

What actually happened?

VS Code and Typescript are yelling at me.

Screenshot 2021-12-12 at 22 38 12

CDK CLI Version

1.94.1

Framework Version

1.134

Node.js Version

16.13.0

OS

MacOS

Language

Typescript

Language Version

Typescript(4.5.2)

Other information

As a workaround, I set // @ts-ignore above that property.

otaviomacedo commented 2 years ago

@jolo-dev can you please make sure that all your @aws-cdk/* dependencies are pointing to the same version? You mentioned that you're using version 1.134, but transferAccelerationUrlForObject was not introduced until version 1.135.0.

jolo-dev commented 2 years ago

@otaviomacedo thanks for your reply. That's weird. I use projen and have chosen cdkVersion: 1.134.0 Will check if the upgrade helps

peterwoodworth commented 2 years ago

This error typically results from misaligned cdk package versions, so the upgrade should help. Let us know if it doesn't

jolo-dev commented 2 years ago

Hi @peterwoodworth,

I use projen and set the cdkVersion: 1.135.0. The error is still yelling :/ Maybe it's a projen bug.

peterwoodworth commented 2 years ago

Have you checked your package.json to verify that all aws-cdk/* packages are the same version? Once you've verified that, delete your node_modules directory and package-lock.json then rerun npm install to verify that your installed packages are all the same version as well.

jolo-dev commented 2 years ago

Cool, that did the trick. Still weird, never had issues when upgrading cdkVersion in projen. Thank you!

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.