Skip to content

Commit 8e090bb

Browse files
authored
fix: use new API to modify configuration (#2)
1 parent ab08fcf commit 8e090bb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ node_modules
1111
/build
1212
.vscode
1313
.env
14+
15+
# Local Netlify folder
16+
.netlify

src/main.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const SECRET_PREFIX = process.env.NETLIFY_AWS_SECRET_PREFIX || 'NETLIFY_AWS_SECR
3838
const getPrefixedKey = (key) => `${SECRET_PREFIX}${key}`
3939

4040
module.exports = {
41-
async onPreBuild({ utils }) {
41+
async onPreBuild({ netlifyConfig, utils }) {
4242
const {
4343
NETLIFY_AWS_ACCESS_KEY_ID: accessKeyId,
4444
NETLIFY_AWS_SECRET_ACCESS_KEY: secretAccessKey,
@@ -60,14 +60,11 @@ module.exports = {
6060
const normalizedSecrets = await normalizeSecrets({ client, secrets })
6161

6262
const entries = Object.entries(normalizedSecrets)
63-
entries.forEach(([key]) => {
64-
console.log(
65-
`${chalk.bold('Injecting AWS secret')} ${chalk.magenta(`${key}`)} as ${chalk.green(getPrefixedKey(key))}`,
66-
)
63+
entries.forEach(([key, value]) => {
64+
const prefixedKey = getPrefixedKey(key)
65+
console.log(`${chalk.bold('Injecting AWS secret')} ${chalk.magenta(`${key}`)} as ${chalk.green(prefixedKey)}`)
66+
// eslint-disable-next-line no-param-reassign
67+
netlifyConfig.build.environment[prefixedKey] = value
6768
})
68-
69-
const prefixedSecrets = Object.fromEntries(entries.map(([key, value]) => [getPrefixedKey(key), value]))
70-
71-
Object.assign(process.env, prefixedSecrets)
7269
},
7370
}

0 commit comments

Comments
 (0)