-
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.
- Loading branch information
Showing
32 changed files
with
350 additions
and
156 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
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
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: buildx-ecr | ||
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,53 @@ | ||
import * as aws from "@pulumi/aws"; | ||
import * as docker from "@pulumi/docker"; | ||
import * as pulumi from "@pulumi/pulumi"; | ||
|
||
// Create a private ECR registry WITHOUT force delete -- our image should be | ||
// deleted during teardown. | ||
const repo = new aws.ecr.Repository("my-repo", {}); | ||
|
||
// 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 { | ||
server: credentials.proxyEndpoint, | ||
username: username, | ||
password: password, | ||
}; | ||
}); | ||
|
||
// Build and publish the image. | ||
const image = new docker.buildx.Image("buildx-pushed-multi-plat", { | ||
tags: [pulumi.interpolate`${repo.repositoryUrl}:buildx`], | ||
push: true, | ||
context: { | ||
location: "app", | ||
}, | ||
registries: [ | ||
{ | ||
address: registryInfo.server, | ||
username: registryInfo.username, | ||
password: registryInfo.password, | ||
}, | ||
], | ||
}); | ||
|
||
const notPushed = new docker.buildx.Image("buildx-not-pushed", { | ||
tags: [pulumi.interpolate`${repo.repositoryUrl}:buildx`], | ||
platforms: ["linux/arm64", "linux/amd64"], | ||
push: false, | ||
context: { | ||
location: "app", | ||
}, | ||
}); | ||
|
||
// Export the resulting image name | ||
export const ref = image.ref; |
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": "buildx-ecr", | ||
"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" | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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.