| 34 | const client = new SecretManagerServiceClient(); |
| 35 | |
| 36 | async function createSecret() { |
| 37 | const secretConfig = { |
| 38 | replication: { |
| 39 | automatic: {}, |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | // Add TTL to the secret configuration if provided |
| 44 | if (ttl) { |
| 45 | secretConfig.ttl = { |
| 46 | seconds: parseInt(ttl.replace('s', ''), 10), |
| 47 | }; |
| 48 | console.log(`Secret TTL set to ${ttl}`); |
| 49 | } |
| 50 | |
| 51 | const [secret] = await client.createSecret({ |
| 52 | parent: parent, |
| 53 | secretId: secretId, |
| 54 | secret: secretConfig, |
| 55 | }); |
| 56 | |
| 57 | console.log(`Created secret ${secret.name}`); |
| 58 | } |
| 59 | |
| 60 | createSecret(); |
| 61 | // [END secretmanager_create_secret] |