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

[ec2] init file for windows returns empty #10390

Closed
abelmokadem opened this issue Sep 16, 2020 · 1 comment · Fixed by #10450
Closed

[ec2] init file for windows returns empty #10390

abelmokadem opened this issue Sep 16, 2020 · 1 comment · Fixed by #10450
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@abelmokadem
Copy link
Contributor

abelmokadem commented Sep 16, 2020

I stumbled on this piece of code in CDK:

protected _standardConfig(fileOptions: InitFileOptions, platform: InitPlatform, contentVars: Record<string, any>): Record<string, any> {
if (platform === InitPlatform.WINDOWS) {
if (fileOptions.group || fileOptions.owner || fileOptions.mode) {
throw new Error('Owner, group, and mode options not supported for Windows.');
}
return {};
}
return {
[this.fileName]: {
...contentVars,
mode: fileOptions.mode || '000644',
owner: fileOptions.owner || 'root',
group: fileOptions.group || 'root',
},
};
}
}

Why is line 492 returning an empty object and not the file? Windows CloudFormation init can also have files. Am I missing something or is this a bug?

Reproduction Steps

Create a Windows ec2 with the init option set and use ec2.InitFile.fromString.

What did you expect to happen?

I expected the CloudFormation init template to contain an entry with the file from the string I provided.

What actually happened?

The CloudFormation init template was empty for the files section: files: {}

I'm missing the files 😢

Environment

  • CLI Version : 1.62.0
  • Framework Version: 1.62.0
  • Node.js Version: 14.7.0
  • OS : OS X
  • Language (Version): TypeScript

Other


This is 🐛 Bug Report

@abelmokadem abelmokadem added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 16, 2020
@abelmokadem
Copy link
Contributor Author

I have "forked" some of the code into my repo and it's working with the following code:

    if (platform === InitPlatform.WINDOWS) {
      if (fileOptions.group || fileOptions.owner || fileOptions.mode) {
        throw new Error("Owner, group, and mode options not supported for Windows.");
      }
      return {
        [this.fileName]: {
          ...contentVars,
        },
      };
    }

    return {
      [this.fileName]: {
        ...contentVars,
        mode: fileOptions.mode || "000644",
        owner: fileOptions.owner || "root",
        group: fileOptions.group || "root",
      },
    };

@SomayaB SomayaB changed the title bug(ec2): init file for windows returns empty [ec2] init file for windows returns empty Sep 16, 2020
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Sep 16, 2020
rix0rrr added a commit that referenced this issue Sep 21, 2020
@mergify mergify bot closed this as completed in #10450 Sep 21, 2020
mergify bot pushed a commit that referenced this issue Sep 21, 2020
Fixes #10390.


----

*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
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants