-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2378 from guardian/ash/explicit-user-data
feat(ec2): Require explicit `UserData` type instead of `string` in Pattern props.
- Loading branch information
Showing
8 changed files
with
94 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
"@guardian/cdk": major | ||
--- | ||
|
||
GuCDK EC2 patterns now require an explicit `UserData` or `GuUserDataProps` input, instead of a string. | ||
|
||
The UserData class comes with helpers that allow us to mutate the user data in our patterns which will be helpful with some of our upcoming work. | ||
Unfortunately whenever a `string` is passed to our patterns we have to wrap it in a special `CustomUserData` class which disables most of these helpers. | ||
|
||
For applications that were already using `GuUserDataProps` no change is required, however applications that used strings will have to make a small change. | ||
|
||
```js | ||
new GuEc2App({ | ||
userData: `#!/usr/bin/bash echo "hello world"`, | ||
... | ||
}) | ||
``` | ||
|
||
becomes | ||
|
||
```js | ||
const userData = UserData.forLinux(); | ||
userData.addCommands(`echo "hello world"`); | ||
|
||
new GuEc2App({ | ||
userData, | ||
... | ||
}) | ||
``` | ||
|
||
Note that you no longer need to specify a shebang, by default `UserData` adds one for you. If you need to customize this behaviour you can look at the props accepted by `forLinux`. | ||
You may also want to look at some of the other methods that UserData has to understand if it may be able to help you in other ways, for example `addS3DownloadCommand` the method helps you write commands to download from S3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.