Skip to content

feat: new ICfn<Resource>#28189

Closed
kaizencc wants to merge 12 commits intomainfrom
conroy/generate
Closed

feat: new ICfn<Resource>#28189
kaizencc wants to merge 12 commits intomainfrom
conroy/generate

Conversation

@kaizencc
Copy link
Copy Markdown
Contributor

Draft PR to run PR build.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

kaizencc and others added 5 commits November 2, 2023 16:46
Generates something that looks like this for all resources:

```ts
interface ICfnResource {
  readonly attrName: string;    // { Ref }, i.e. the primaryIdentifier
  readonly attrArn: string;     // { Fn::GetAtt }, if applicable
}
```

In a separate PR, we will update all `CfnResource`s to extend
`ICfnResource`, and then later on, update some `Resource`s to extend
`ICfnResource` as well.

**This PR targets `conroy/generate` as a horribly named branch off of
`main` which will house all pieces of this puzzle before unleashing onto
`main`.**


----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*

---------

Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
We've decided that `ICfnResource` should extend `IConstruct`. In
addition, I've changed the linter error to correctly reference where
`IConstruct` is coming from. I'll keep it a mystery as to whether I
realized beforehand or tried to extend `core.IConstruct` first.

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
Introducing two new rules, and immediately accepting all current
violations.

- `resource-interface-extends-resource-ref` - all resources interfaces
like `IBucket` must also implement the reference interface, e.g.
`ICfnBucket`
- `ref-via-ref-interface` - all APIs should accept the reference
interface `ICfnBucket` over the resource interface `IBucket`

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
This PR implements the following:

- If all `primaryIdentifiers` are `attributes`, there is nothing to do;
`ICfnResource` is already implemented by `Resource`
- if all `primaryIdentifiers` are `properties`, then
- if there is 1 `primaryIdentifier` initialize it as `this.attrId =
this.ref;`
- if there are multiple `primaryIdentifiers` initialize each as
`this.attrId = cdk.Fn.select(0, cdk.Fn.split('|', this.ref));` and so on

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*

---------

Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
…28179)

They should all be required. Anything returned from `ref` will exist,
even if the property itself is not required. For example,
`CfnBucket.attrBucketName` is not required in the resource spec because
you can either specify a bucket name or have one generated for you.
However, when accessing it via `ref`, the bucket name will certainly
exist, so it is not optional.

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
@aws-cdk-automation aws-cdk-automation requested a review from a team November 29, 2023 19:02
@github-actions github-actions bot added the p2 label Nov 29, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 29, 2023
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@kaizencc kaizencc added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Nov 29, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 29, 2023 19:15

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

kaizencc and others added 6 commits December 1, 2023 16:11
This is a best-effort migration of `IBucket` usage in aws-cdk-lib to
`ICfnBucket`. In places where we rely on a property specific to
`IBucket`, we use `Bucket.fromCfnBucket(iCfnBucket)` to generate an
`IBucket` to use.

----

<img width="285" alt="image"
src="https://github.com/aws/aws-cdk/assets/36202692/7a86396b-8193-4df6-a145-c5d5126dc8f1">



----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
Migrate inputs of `IQueue` to `ICfnQueue` wherever possible. 

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 195a319
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants