Skip to content

Commit ea8f175

Browse files
committed
fix: don't use reserved names
1 parent d2978ce commit ea8f175

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Diff for: README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Inject secrets from AWS Secrets Manager into the Netlify build process.
77

88
## Prerequisites
99

10-
- `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` set as build environment variables with proper permissions, e.g.
10+
- `NETLIFY_AWS_ACCESS_KEY_ID` and `NETLIFY_AWS_SECRET_ACCESS_KEY` set as build environment variables with proper
11+
permissions, e.g.
1112

1213
```json
1314
{
@@ -55,10 +56,10 @@ package = "@netlify/plugin-secrets-manager"
5556

5657
## Additional configuration
5758

58-
- By default the plugin injects the secrets with a `AWS_SECRET_` prefix. You can override the default prefix using the
59-
`AWS_SECRET_PREFIX` environment variable.
60-
- The plugin defaults to the `us-east-1` region. You can override the default region using the `AWS_DEFAULT_REGION`
61-
environment variable.
59+
- By default the plugin injects the secrets with a `NETLIFY_AWS_SECRET_` prefix. You can override the default prefix
60+
using the `NETLIFY_AWS_SECRET_PREFIX` environment variable.
61+
- The plugin defaults to the `us-east-1` region. You can override the default region using the
62+
`NETLIFY_AWS_DEFAULT_REGION` environment variable.
6263

6364
## Contributors
6465

Diff for: netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
command = "echo $AWS_SECRET_SECRET_NAME"
2+
command = "echo $NETLIFY_AWS_SECRET_SECRET_NAME"
33
publish = "public"
44
[[plugins]]
55
package = "."

Diff for: src/main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ const normalizeSecrets = async ({ client, secrets }) => {
3333
return Object.assign({}, ...values)
3434
}
3535

36-
const SECRET_PREFIX = process.env.AWS_SECRET_PREFIX || 'AWS_SECRET_'
36+
const SECRET_PREFIX = process.env.NETLIFY_AWS_SECRET_PREFIX || 'NETLIFY_AWS_SECRET_'
3737

3838
const getPrefixedKey = (key) => `${SECRET_PREFIX}${key}`
3939

4040
module.exports = {
4141
async onPreBuild({ utils }) {
4242
const {
43-
AWS_ACCESS_KEY_ID: accessKeyId,
44-
AWS_SECRET_ACCESS_KEY: secretAccessKey,
45-
AWS_DEFAULT_REGION: region = 'us-east-1',
43+
NETLIFY_AWS_ACCESS_KEY_ID: accessKeyId,
44+
NETLIFY_AWS_SECRET_ACCESS_KEY: secretAccessKey,
45+
NETLIFY_AWS_DEFAULT_REGION: region = 'us-east-1',
4646
} = process.env
4747
if (!accessKeyId) {
48-
return utils.build.failBuild(`Missing environment variable AWS_ACCESS_KEY_ID`)
48+
return utils.build.failBuild(`Missing environment variable NETLIFY_AWS_ACCESS_KEY_ID`)
4949
}
5050

5151
if (!secretAccessKey) {
52-
return utils.build.failBuild(`Missing environment variable AWS_SECRET_ACCESS_KEY`)
52+
return utils.build.failBuild(`Missing environment variable NETLIFY_AWS_SECRET_ACCESS_KEY`)
5353
}
5454

5555
const client = new SecretsManagerClient({

Diff for: test/main.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const test = require('ava')
33

44
const NETLIFY_CONFIG = `${__dirname}/../netlify.toml`
55

6-
test('Netlify Build fails when missing AWS_ACCESS_KEY_ID env variable', async (t) => {
6+
test('Netlify Build fails when missing NETLIFY_AWS_ACCESS_KEY_ID env variable', async (t) => {
77
const { success, logs } = await netlifyBuild({
88
env: {},
99
config: NETLIFY_CONFIG,
@@ -13,25 +13,25 @@ test('Netlify Build fails when missing AWS_ACCESS_KEY_ID env variable', async (t
1313
t.is(success, false)
1414

1515
const output = logs.stdout.join('')
16-
t.true(output.includes('Missing environment variable AWS_ACCESS_KEY_ID'))
16+
t.true(output.includes('Missing environment variable NETLIFY_AWS_ACCESS_KEY_ID'))
1717
})
1818

19-
test('Netlify Build fails when missing AWS_SECRET_ACCESS_KEY env variable', async (t) => {
19+
test('Netlify Build fails when missing NETLIFY_AWS_SECRET_ACCESS_KEY env variable', async (t) => {
2020
const { success, logs } = await netlifyBuild({
21-
env: { AWS_ACCESS_KEY_ID: 'test' },
21+
env: { NETLIFY_AWS_ACCESS_KEY_ID: 'test' },
2222
config: NETLIFY_CONFIG,
2323
buffer: true,
2424
})
2525

2626
t.is(success, false)
2727

2828
const output = logs.stdout.join('')
29-
t.true(output.includes('Missing environment variable AWS_SECRET_ACCESS_KEY'))
29+
t.true(output.includes('Missing environment variable NETLIFY_AWS_SECRET_ACCESS_KEY'))
3030
})
3131

32-
test('Netlify Build fails when AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are invalid', async (t) => {
32+
test('Netlify Build fails when NETLIFY_AWS_ACCESS_KEY_ID and NETLIFY_AWS_SECRET_ACCESS_KEY are invalid', async (t) => {
3333
const { success, logs } = await netlifyBuild({
34-
env: { AWS_ACCESS_KEY_ID: 'test', AWS_SECRET_ACCESS_KEY: 'test' },
34+
env: { NETLIFY_AWS_ACCESS_KEY_ID: 'test', NETLIFY_AWS_SECRET_ACCESS_KEY: 'test' },
3535
config: NETLIFY_CONFIG,
3636
buffer: true,
3737
})

0 commit comments

Comments
 (0)