-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to ignore changes to volatile provider configuration
The password and username of the registryAuth config can be volatile for many cloud registries. For AWS ECR you need to exchange AWS credentials for short lived tokens to authenticate to the registry. This will lead to perma-diffs in the provider config. This change adds the ability to ignore certain volatile fields of the registryAuth configuration.
- Loading branch information
1 parent
26c9c62
commit 94b8ac0
Showing
8 changed files
with
239 additions
and
1 deletion.
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
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,2 @@ | ||
/bin/ | ||
/node_modules/ |
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,3 @@ | ||
name: registry-token-auth | ||
runtime: nodejs | ||
description: A minimal AWS TypeScript Pulumi program |
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,3 @@ | ||
FROM nginx | ||
RUN echo "<h1>Hi from Pulumi!</h1>" > \ | ||
/usr/share/nginx/html/index.html |
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,49 @@ | ||
import * as aws from "@pulumi/aws"; | ||
import * as docker from "@pulumi/docker"; | ||
|
||
// Create a private ECR registry. | ||
const repo = new aws.ecr.Repository("my-repo", { | ||
forceDelete: true, | ||
}); | ||
|
||
// Get registry info (creds and endpoint) so we can build/publish to it. | ||
const registryInfo = repo.registryId.apply(async id => { | ||
const credentials = await aws.ecr.getCredentials({ registryId: id }); | ||
const decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString(); | ||
const [username, password] = decodedCredentials.split(":"); | ||
if (!password || !username) { | ||
throw new Error("Invalid credentials"); | ||
} | ||
return { | ||
address: credentials.proxyEndpoint, | ||
username: username, | ||
password: password, | ||
}; | ||
}); | ||
|
||
|
||
// Build image to simulate a local image | ||
const image = new docker.Image("my-image", { | ||
build: { | ||
context: "app", | ||
}, | ||
imageName: repo.repositoryUrl, | ||
skipPush: true | ||
}); | ||
|
||
const ecrProvider = new docker.Provider("ecr-provider", { | ||
registryAuth: [registryInfo], | ||
}, | ||
); | ||
|
||
// Publish the image to the registry | ||
const registryImage = new docker.RegistryImage("my-registry-image", | ||
{ | ||
name: repo.repositoryUrl, | ||
}, | ||
{ provider: ecrProvider, dependsOn: [image] }, | ||
); | ||
|
||
// Export the resulting image name | ||
export const imageName = image.imageName; | ||
export const repoDigest = image.repoDigest; |
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,11 @@ | ||
{ | ||
"name": "cbp-aws-ts", | ||
"devDependencies": { | ||
"@types/node": "^14.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^6.10.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"@pulumi/random": "^4.14.0" | ||
} | ||
} |
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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
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