Repository navigation
Expand file tree
/
Copy pathcodeartifact.tf
More file actions
58 lines (46 loc) · 1.8 KB
/
Copy pathcodeartifact.tf
File metadata and controls
58 lines (46 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Private npm registry via AWS CodeArtifact
# CodeArtifact is not available in us-west-1, use us-west-2
provider "aws" {
alias = "usw2"
region = "us-west-2"
}
resource "aws_codeartifact_domain" "main" {
provider = aws.usw2
domain = "ejc3"
tags = { Name = "ejc3-codeartifact" }
}
resource "aws_codeartifact_repository" "npm" {
provider = aws.usw2
repository = "npm"
domain = aws_codeartifact_domain.main.domain
upstream {
repository_name = aws_codeartifact_repository.npm_upstream.repository
}
tags = { Name = "ejc3-npm" }
}
# Upstream proxy to public npmjs.com (so you can install public packages through CodeArtifact too)
resource "aws_codeartifact_repository" "npm_upstream" {
provider = aws.usw2
repository = "npm-upstream"
domain = aws_codeartifact_domain.main.domain
external_connections {
external_connection_name = "public:npmjs"
}
tags = { Name = "ejc3-npm-upstream" }
}
# Same-account dev publishers continue using their identity policies. Remove the
# old shared CI role's resource-policy token/publish grants; the repositories and
# existing packages remain intact. CI has no replacement package-publishing grant.
# Outputs
output "npm_registry_domain" {
description = "CodeArtifact domain name"
value = aws_codeartifact_domain.main.domain
}
output "npm_registry_repository" {
description = "CodeArtifact repository name"
value = aws_codeartifact_repository.npm.repository
}
output "npm_registry_endpoint" {
description = "npm registry endpoint (use with: aws codeartifact login --tool npm)"
value = "aws codeartifact login --tool npm --domain ${aws_codeartifact_domain.main.domain} --domain-owner ${data.aws_caller_identity.current.account_id} --repository ${aws_codeartifact_repository.npm.repository} --region us-west-2"
}