Skip to content

Commit 0c77182

Browse files
committed
Add support for ArtifactsBucket region and ACL config, make ArtifactsBucket usable
Introduces ArtifactsBucketRegion and ArtifactsS3ACL parameters to aws-stack.yml, allowing configuration of S3 region and ACL for artifact uploads. Updates Linux and Windows install scripts to set related environment variables if an artifacts bucket is specified based off feedback from an issue Fixes #640
1 parent ff48e8f commit 0c77182

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

packer/linux/conf/bin/bk-install-elastic-stack.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ set_always "BUILDKITE_DOCKER_EXPERIMENTAL" "$DOCKER_EXPERIMENTAL"
145145
set_always "DOCKER_USERNS_REMAP" "$DOCKER_USERNS_REMAP"
146146
set_always "DOCKER_VERSION" "$DOCKER_VERSION"
147147
set_always "PLUGINS_ENABLED" "${PLUGINS_ENABLED[*]-}"
148+
set_always "BUILDKITE_ARTIFACTS_BUCKET" "$BUILDKITE_ARTIFACTS_BUCKET"
149+
set_always "BUILDKITE_S3_DEFAULT_REGION" "$BUILDKITE_S3_DEFAULT_REGION"
150+
set_always "BUILDKITE_S3_ACL" "$BUILDKITE_S3_ACL"
148151
set_unless_present "AWS_DEFAULT_REGION" "$AWS_REGION"
149152
set_unless_present "AWS_REGION" "$AWS_REGION"
150153
EOF

packer/windows/conf/bin/bk-install-elastic-stack.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ set_always "BUILDKITE_STACK_VERSION" "$Env:BUILDKITE_STACK_VERSION"
8484
set_always "BUILDKITE_DOCKER_EXPERIMENTAL" "$DOCKER_EXPERIMENTAL"
8585
set_always "DOCKER_VERSION" "$DOCKER_VERSION"
8686
set_always "PLUGINS_ENABLED" "$PLUGINS_ENABLED"
87+
set_always "BUILDKITE_ARTIFACTS_BUCKET" "$Env:BUILDKITE_ARTIFACTS_BUCKET"
88+
set_always "BUILDKITE_S3_DEFAULT_REGION" "$Env:BUILDKITE_S3_DEFAULT_REGION"
89+
set_always "BUILDKITE_S3_ACL" "$Env:BUILDKITE_S3_ACL"
8790
set_unless_present "AWS_DEFAULT_REGION" "$Env:AWS_REGION"
8891
set_unless_present "AWS_REGION" "$Env:AWS_REGION"
8992
set_unless_present "BUILDKITE_AGENT_ENDPOINT" "https://agent.buildkite.com/v3"

templates/aws-stack.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Metadata:
8686
- SecretsBucketRegion
8787
- SecretsBucketEncryption
8888
- ArtifactsBucket
89+
- ArtifactsBucketRegion
90+
- ArtifactsS3ACL
8991
- AuthorizedUsersUrl
9092
- BootstrapScriptUrl
9193
- AgentEnvFileUrl
@@ -399,6 +401,24 @@ Parameters:
399401
Type: String
400402
Default: ""
401403

404+
ArtifactsBucketRegion:
405+
Description: Optional - Region for the ArtifactsBucket. If blank the bucket's region is dynamically discovered.
406+
Type: String
407+
Default: ""
408+
409+
ArtifactsS3ACL:
410+
Description: Optional - ACL to use for S3 artifact uploads
411+
Type: String
412+
AllowedValues:
413+
- "private"
414+
- "public-read"
415+
- "public-read-write"
416+
- "authenticated-read"
417+
- "aws-exec-read"
418+
- "bucket-owner-read"
419+
- "bucket-owner-full-control"
420+
Default: "private"
421+
402422
BootstrapScriptUrl:
403423
Description: Optional - HTTPS or S3 URL for a script to run on each instance during boot
404424
Type: String
@@ -879,13 +899,13 @@ Conditions:
879899

880900
UseInstanceType7:
881901
!Not [ !Equals [ !Select [ "6", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
882-
902+
883903
UseInstanceType8:
884904
!Not [ !Equals [ !Select [ "7", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
885-
905+
886906
UseInstanceType9:
887907
!Not [ !Equals [ !Select [ "8", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
888-
908+
889909
UseInstanceType10:
890910
!Not [ !Equals [ !Select [ "9", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
891911

@@ -894,13 +914,13 @@ Conditions:
894914

895915
UseInstanceType12:
896916
!Not [ !Equals [ !Select [ "11", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
897-
917+
898918
UseInstanceType13:
899919
!Not [ !Equals [ !Select [ "12", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
900920

901921
UseInstanceType14:
902922
!Not [ !Equals [ !Select [ "13", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
903-
923+
904924
UseInstanceType15:
905925
!Not [ !Equals [ !Select [ "14", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
906926

@@ -909,13 +929,13 @@ Conditions:
909929

910930
UseInstanceType17:
911931
!Not [ !Equals [ !Select [ "16", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
912-
932+
913933
UseInstanceType18:
914934
!Not [ !Equals [ !Select [ "17", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
915-
935+
916936
UseInstanceType19:
917937
!Not [ !Equals [ !Select [ "18", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
918-
938+
919939
UseInstanceType20:
920940
!Not [ !Equals [ !Select [ "19", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
921941

@@ -927,7 +947,7 @@ Conditions:
927947

928948
UseInstanceType23:
929949
!Not [ !Equals [ !Select [ "22", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
930-
950+
931951
UseInstanceType24:
932952
!Not [ !Equals [ !Select [ "23", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
933953

@@ -1556,6 +1576,9 @@ Resources:
15561576
$Env:BUILDKITE_SCALE_IN_IDLE_PERIOD="${ScaleInIdlePeriod}"
15571577
$Env:BUILDKITE_SECRETS_BUCKET="${LocalSecretsBucket}"
15581578
$Env:BUILDKITE_SECRETS_BUCKET_REGION="${LocalSecretsBucketRegion}"
1579+
$Env:BUILDKITE_ARTIFACTS_BUCKET="${ArtifactsBucket}"
1580+
$Env:BUILDKITE_S3_DEFAULT_REGION="${LocalArtifactsBucketRegion}"
1581+
$Env:BUILDKITE_S3_ACL="${ArtifactsS3ACL}"
15591582
$Env:BUILDKITE_AGENT_TOKEN_PATH="${AgentTokenPath}"
15601583
$Env:BUILDKITE_AGENTS_PER_INSTANCE="${AgentsPerInstance}"
15611584
$Env:BUILDKITE_AGENT_ENDPOINT="${AgentEndpoint}"
@@ -1590,6 +1613,13 @@ Resources:
15901613
- CreateSecretsBucket
15911614
- !Ref "AWS::Region"
15921615
- !Ref SecretsBucketRegion
1616+
LocalArtifactsBucketRegion: !If
1617+
- UseArtifactsBucket
1618+
- !If
1619+
- !Equals [ !Ref ArtifactsBucketRegion, "" ]
1620+
- !Ref "AWS::Region"
1621+
- !Ref ArtifactsBucketRegion
1622+
- !Ref "AWS::Region"
15931623
AgentTokenPath: !If
15941624
- UseCustomerManagedParameterPath
15951625
- !Ref BuildkiteAgentTokenParameterStorePath
@@ -1632,6 +1662,9 @@ Resources:
16321662
BUILDKITE_SCALE_IN_IDLE_PERIOD="${ScaleInIdlePeriod}" \
16331663
BUILDKITE_SECRETS_BUCKET="${LocalSecretsBucket}" \
16341664
BUILDKITE_SECRETS_BUCKET_REGION="${LocalSecretsBucketRegion}" \
1665+
BUILDKITE_ARTIFACTS_BUCKET="${ArtifactsBucket}" \
1666+
BUILDKITE_S3_DEFAULT_REGION="${LocalArtifactsBucketRegion}" \
1667+
BUILDKITE_S3_ACL="${ArtifactsS3ACL}" \
16351668
BUILDKITE_AGENT_TOKEN_PATH="${AgentTokenPath}" \
16361669
BUILDKITE_AGENTS_PER_INSTANCE="${AgentsPerInstance}" \
16371670
BUILDKITE_AGENT_ENDPOINT="${AgentEndpoint}" \
@@ -1678,6 +1711,13 @@ Resources:
16781711
- CreateSecretsBucket
16791712
- !Ref "AWS::Region"
16801713
- !Ref SecretsBucketRegion
1714+
LocalArtifactsBucketRegion: !If
1715+
- UseArtifactsBucket
1716+
- !If
1717+
- !Equals [ !Ref ArtifactsBucketRegion, "" ]
1718+
- !Ref "AWS::Region"
1719+
- !Ref ArtifactsBucketRegion
1720+
- !Ref "AWS::Region"
16811721
AgentTokenPath: !If
16821722
- UseCustomerManagedParameterPath
16831723
- !Ref BuildkiteAgentTokenParameterStorePath

0 commit comments

Comments
 (0)