Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(glue): change physical name to optional #23221

Merged
merged 5 commits into from
Dec 7, 2022

Conversation

WinterYukky
Copy link
Contributor

@WinterYukky WinterYukky commented Dec 4, 2022

Currently, we must set the physical name in the Glue L2 Constructs. This is not abide by the CDK Best Practices.
So, this mean also customer can not abide by the best practices too.

example

const myDatabase = new glue.Database(this, "MyDatabase", {
    databaseName: "my-database", // need
})
new glue.Table(this, "MyTable", {
    tableName: "my-tabel", // need
    database: myDatabase,
    columns: [...]
})

This PR fix physicalName in props to optonal and when not privided physicalName then generate physicalName by CDK.
Then customers can abide by the best practices and no more coding while worrying about physical name conflicts.

example after fixed

const myDatabase = new glue.Database(this, "MyDatabase")
new glue.Table(this, "MyTable", {
    database: myDatabase,
    columns: [...]
})

Also fixd the documents.


All Submissions:

Adding new Construct Runtime Dependencies:

  • This PR adds new construct runtime dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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

@gitpod-io
Copy link

gitpod-io bot commented Dec 4, 2022

@github-actions github-actions bot added the valued-contributor [Pilot] contributed between 6-12 PRs to the CDK label Dec 4, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team December 4, 2022 06:30
@github-actions github-actions bot added the p2 label Dec 4, 2022
Comment on lines +94 to +96
Lazy.string({
produce: () => Names.uniqueResourceName(this, {}).toLowerCase(),
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

why use a Lazy here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to use toLowerCase()?

Copy link
Contributor Author

@WinterYukky WinterYukky Dec 6, 2022

Choose a reason for hiding this comment

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

why use a Lazy here?

Because physicalName should set in the super. However, when we call the super, we can't use this for Names so we should use a Lazy. Also we can looks this pattern in a other packages (e.g aws-stepfunctions/Activity)

  constructor(scope: Construct, id: string, props: ActivityProps = {}) {
    super(scope, id, {
      physicalName: props.activityName ||
                Lazy.string({ produce: () => this.generateName() }),
    });

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-stepfunctions/lib/activity.ts#L60-L64


Do we have to use toLowerCase()?

Yes, AWS::Glue::Database.DatabaseInput.Name and AWS::Glue::Table.TableInput.Name must be lowercase.

When I use uppercase, I got the error.
image

@comcalvi comcalvi self-assigned this Dec 5, 2022
@mergify mergify bot dismissed comcalvi’s stale review December 6, 2022 13:36

Pull request has been modified.

Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

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

Nice work!

@mergify
Copy link
Contributor

mergify bot commented Dec 6, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mrgrain
Copy link
Contributor

mrgrain commented Dec 7, 2022

@Mergifyio requeue

@mergify
Copy link
Contributor

mergify bot commented Dec 7, 2022

requeue

☑️ This pull request is already queued

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 1a489a6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit bef86f6 into aws:main Dec 7, 2022
@mergify
Copy link
Contributor

mergify bot commented Dec 7, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

brennanho pushed a commit to brennanho/aws-cdk that referenced this pull request Dec 9, 2022
Currently, we must set the physical name in the Glue L2 Constructs. This is not abide by the [CDK Best Practices](https://docs.aws.amazon.com/cdk/v2/guide/best-practices.html#best-practices-apps-names).
So, this mean also customer can not abide by the best practices too. 

example
```ts
const myDatabase = new glue.Database(this, "MyDatabase", {
    databaseName: "my-database", // need
})
new glue.Table(this, "MyTable", {
    tableName: "my-tabel", // need
    database: myDatabase,
    columns: [...]
})
```

This PR fix physicalName in props to optonal and when not privided physicalName then generate physicalName by CDK. 
Then customers can abide by the best practices and no more coding while worrying about physical name conflicts.

example after fixed
```ts
const myDatabase = new glue.Database(this, "MyDatabase")
new glue.Table(this, "MyTable", {
    database: myDatabase,
    columns: [...]
})
```

Also fixd the documents.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
brennanho pushed a commit to brennanho/aws-cdk that referenced this pull request Jan 20, 2023
Currently, we must set the physical name in the Glue L2 Constructs. This is not abide by the [CDK Best Practices](https://docs.aws.amazon.com/cdk/v2/guide/best-practices.html#best-practices-apps-names).
So, this mean also customer can not abide by the best practices too. 

example
```ts
const myDatabase = new glue.Database(this, "MyDatabase", {
    databaseName: "my-database", // need
})
new glue.Table(this, "MyTable", {
    tableName: "my-tabel", // need
    database: myDatabase,
    columns: [...]
})
```

This PR fix physicalName in props to optonal and when not privided physicalName then generate physicalName by CDK. 
Then customers can abide by the best practices and no more coding while worrying about physical name conflicts.

example after fixed
```ts
const myDatabase = new glue.Database(this, "MyDatabase")
new glue.Table(this, "MyTable", {
    database: myDatabase,
    columns: [...]
})
```

Also fixd the documents.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
brennanho pushed a commit to brennanho/aws-cdk that referenced this pull request Feb 22, 2023
Currently, we must set the physical name in the Glue L2 Constructs. This is not abide by the [CDK Best Practices](https://docs.aws.amazon.com/cdk/v2/guide/best-practices.html#best-practices-apps-names).
So, this mean also customer can not abide by the best practices too. 

example
```ts
const myDatabase = new glue.Database(this, "MyDatabase", {
    databaseName: "my-database", // need
})
new glue.Table(this, "MyTable", {
    tableName: "my-tabel", // need
    database: myDatabase,
    columns: [...]
})
```

This PR fix physicalName in props to optonal and when not privided physicalName then generate physicalName by CDK. 
Then customers can abide by the best practices and no more coding while worrying about physical name conflicts.

example after fixed
```ts
const myDatabase = new glue.Database(this, "MyDatabase")
new glue.Table(this, "MyTable", {
    database: myDatabase,
    columns: [...]
})
```

Also fixd the documents.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants