Skip to content

Introduce AWS provider s3 directory path variables - #9904

Closed
remi00 wants to merge 7 commits into
serverless:mainfrom
remi00:provider-s3-directories
Closed

remi00 wants to merge 7 commits into
serverless:mainfrom
remi00:provider-s3-directories

Conversation

@remi00

@remi00 remi00 commented Sep 1, 2021

Copy link
Copy Markdown
Contributor

What it does?

  • Introduce AWS provider s3 directory path variables that will allow for proper directory structure within artifacts S3 bucket once hash artifacts versioning will be added

What else is important?

@codecov

codecov Bot commented Sep 1, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #9904 (d7ad338) into master (7bb2520) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9904   +/-   ##
=======================================
  Coverage   85.34%   85.35%           
=======================================
  Files         339      339           
  Lines       13822    13831    +9     
=======================================
+ Hits        11797    11806    +9     
  Misses       2025     2025           
Impacted Files Coverage Δ
lib/plugins/aws/deploy/lib/extendedValidate.js 95.23% <ø> (ø)
lib/plugins/aws/package/compile/functions.js 94.44% <ø> (ø)
lib/plugins/aws/package/lib/saveServiceState.js 100.00% <ø> (ø)
lib/plugins/aws/customResources/index.js 98.61% <100.00%> (ø)
lib/plugins/aws/deploy/lib/uploadArtifacts.js 91.00% <100.00%> (+0.18%) ⬆️
lib/plugins/aws/deploy/lib/validateTemplate.js 100.00% <100.00%> (ø)
lib/plugins/aws/lib/updateStack.js 98.61% <100.00%> (ø)
lib/plugins/aws/package/compile/layers.js 84.21% <100.00%> (ø)
...s/aws/package/lib/generateArtifactDirectoryName.js 100.00% <100.00%> (ø)
lib/plugins/aws/provider.js 94.47% <100.00%> (+0.18%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7bb2520...d7ad338. Read the comment docs.

@remi00

remi00 commented Sep 20, 2021

Copy link
Copy Markdown
Contributor Author

Hello @medikoo could you please take a look? Do these changes make sense from your point of view?

@medikoo medikoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @remi00 and sorry that it took us so long to review that (for some reason it got lost in a process, and it's great you've reminded us)

In general it looks very good, I have just few suggestions

Comment on lines +1602 to +1603
provider.s3CodeArtifactsDirectoryPath = `${prefix}/${serviceStage}/code-artifacts`;
provider.s3DeploymentDirectoryPath = `${prefix}/${serviceStage}/${dateString}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not set it on service.provider, this object reflects user configuration and ideally if we do not mix it with internally resolved data (although I know that currently our internals in few places do that).

Ideally if s3CodeArtifactsDirectoryPath and s3DeploymentDirectoryPath getters simply resolve it on spot
And timestamp part can be set on provider instance in its constructor as e.g. this.deploymentTimestamp = ...

const dateString = `${date.getTime().toString()}-${date.toISOString()}`;
const prefix = this.provider.getDeploymentPrefix();

provider.s3CodeArtifactsDirectoryPath = `${prefix}/${serviceStage}/code-artifacts`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In context of this PR we should not yet introduce s3CodeArtifactsDirectoryPath

provider.s3DeploymentDirectoryPath = `${prefix}/${serviceStage}/${dateString}`;
}

get s3CodeArtifactsDirectoryPath() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In context of this PR we should not yet introduce s3CodeArtifactsDirectoryPath, as so far path is same as s3DeploymentDirectoryPath.

}

service.package.artifactDirectoryName = `${prefix}/${dateString}`;
service.provider.s3DeploymentDirectoryPath = `${prefix}/${dateString}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think here what should be overriden is just serverless.getProvider('aws').deploymentTimestamp and having that getters should start resolve the right deployment path (?)

beforeEach(() => {
awsProvider.hooks.initialize();
});
it('should provide proper code artifacts S3 directory path', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any new tests should be based on runServerless util, e.g. see how provider.getRegion() is tested:

describe('#getRegion()', () => {
it('should default to "us-east-1"', async () => {
const { serverless } = await runServerless({
fixture: 'aws',
command: 'print',
});
expect(serverless.getProvider('aws').getRegion()).to.equal('us-east-1');
});
it('should allow to override via `provider.region`', async () => {
const { serverless } = await runServerless({
fixture: 'aws',
command: 'print',
configExt: {
provider: {
region: 'eu-central-1',
},
},
});
expect(serverless.getProvider('aws').getRegion()).to.equal('eu-central-1');
});
it('should allow to override via CLI `--region` param', async () => {
const { serverless } = await runServerless({
fixture: 'aws',
command: 'print',
options: { region: 'us-west-1' },
configExt: {
provider: {
region: 'eu-central-1',
},
},
});
expect(serverless.getProvider('aws').getRegion()).to.equal('us-west-1');
});
});

@remi00

remi00 commented Nov 3, 2021

Copy link
Copy Markdown
Contributor Author

@wwwehr you mentioned in #9876 there are some changes already in the baseline that handle this. Could you point me to them? Looks like it was not obvious to me yesterday evening. @medikoo maybe you know and can help?

@remi00

remi00 commented Nov 27, 2023

Copy link
Copy Markdown
Contributor Author

This is already far away from possibility of merging to main

@remi00 remi00 closed this Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants