Skip to content

Commit de7f4ca

Browse files
New CodeBuild workflow (#366)
* Use new CodeBuild workflow
1 parent 02a6f17 commit de7f4ca

File tree

7 files changed

+98
-3
lines changed

7 files changed

+98
-3
lines changed

codebuild/samples/connect-linux.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
env
7+
8+
pushd $CODEBUILD_SRC_DIR/samples/
9+
10+
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
11+
12+
echo "Basic Connect test"
13+
python3 basic_connect.py --endpoint $ENDPOINT --key /tmp/privatekey.pem --cert /tmp/certificate.pem
14+
15+
echo "Websocket Connect test"
16+
python3 websocket_connect.py --endpoint $ENDPOINT --signing_region us-east-1
17+
18+
popd
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
env
7+
8+
pushd $CODEBUILD_SRC_DIR/samples/
9+
10+
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
11+
AUTH_NAME=$(aws secretsmanager get-secret-value --secret-id "ci/CustomAuthorizer/name" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
12+
AUTH_PASSWORD=$(aws secretsmanager get-secret-value --secret-id "ci/CustomAuthorizer/password" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
13+
14+
echo "Custom Authorizer test"
15+
python3 custom_authorizer_connect.py --endpoint $ENDPOINT --custom_auth_authorizer_name $AUTH_NAME --custom_auth_password $AUTH_PASSWORD
16+
17+
popd
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
# Assumes are running using the Ubuntu Codebuild standard image
2+
# NOTE: This script assumes that the AWS CLI-V2 is pre-installed!
3+
# - AWS CLI-V2 is a requirement to run this script.
14
version: 0.2
25
phases:
36
install:
47
commands:
58
- add-apt-repository ppa:ubuntu-toolchain-r/test
69
- apt-get update -y
710
- apt-get install python3 softhsm -y
11+
- echo "\nBuild version data:"
12+
- echo "\nPython Version:"; python3 --version
13+
- echo "\nSoftHSM (PKCS11) version:"; softhsm2-util --version
14+
- echo "\n"
815
build:
916
commands:
1017
- echo Build started on `date`
1118
- $CODEBUILD_SRC_DIR/codebuild/samples/setup-linux.sh
19+
- $CODEBUILD_SRC_DIR/codebuild/samples/connect-linux.sh
20+
- $CODEBUILD_SRC_DIR/codebuild/samples/custom-auth-linux.sh
21+
- $CODEBUILD_SRC_DIR/codebuild/samples/pkcs11-connect-linux.sh
1222
- $CODEBUILD_SRC_DIR/codebuild/samples/pubsub-linux.sh
23+
- $CODEBUILD_SRC_DIR/codebuild/samples/shadow-linux.sh
1324
post_build:
1425
commands:
1526
- echo Build completed on `date`
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
pushd $CODEBUILD_SRC_DIR/samples/
7+
8+
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
9+
10+
# from hereon commands are echoed. don't leak secrets
11+
set -x
12+
13+
softhsm2-util --version
14+
15+
# SoftHSM2's default tokendir path might be invalid on this machine
16+
# so set up a conf file that specifies a known good tokendir path
17+
mkdir -p /tmp/tokens
18+
export SOFTHSM2_CONF=/tmp/softhsm2.conf
19+
echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf
20+
21+
# create token
22+
softhsm2-util --init-token --free --label my-token --pin 0000 --so-pin 0000
23+
24+
# add private key to token (must be in PKCS#8 format)
25+
openssl pkcs8 -topk8 -in /tmp/privatekey.pem -out /tmp/privatekey.p8.pem -nocrypt
26+
softhsm2-util --import /tmp/privatekey.p8.pem --token my-token --label my-key --id BEEFCAFE --pin 0000
27+
28+
# run sample
29+
python3 pkcs11_connect.py --endpoint $ENDPOINT --cert /tmp/certificate.pem --pkcs11_lib /usr/lib/softhsm/libsofthsm2.so --pin 0000 --token_label my-token --key_label my-key
30+
31+
popd

codebuild/samples/pubsub-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
22

33
set -e
4+
set -o pipefail
45

56
env
67

78
pushd $CODEBUILD_SRC_DIR/samples/
89

9-
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
10+
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
1011

1112
echo "PubSub test"
1213
python3 pubsub.py --endpoint $ENDPOINT --key /tmp/privatekey.pem --cert /tmp/certificate.pem

codebuild/samples/setup-linux.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
set -e
4+
set -o pipefail
45

56
env
67

@@ -10,5 +11,6 @@ cd $CODEBUILD_SRC_DIR
1011
ulimit -c unlimited
1112
python3 -m pip install .
1213

13-
cert=$(aws secretsmanager get-secret-value --secret-id "unit-test/certificate" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem
14-
key=$(aws secretsmanager get-secret-value --secret-id "unit-test/privatekey" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem
14+
cert=$(aws secretsmanager get-secret-value --secret-id "ci/CodeBuild/cert" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$cert" > /tmp/certificate.pem
15+
key=$(aws secretsmanager get-secret-value --secret-id "ci/CodeBuild/key" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key" > /tmp/privatekey.pem
16+
key_p8=$(aws secretsmanager get-secret-value --secret-id "ci/CodeBuild/keyp8" --query "SecretString" | cut -f2 -d":" | cut -f2 -d\") && echo -e "$key_p8" > /tmp/privatekey_p8.pem

codebuild/samples/shadow-linux.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
env
7+
8+
pushd $CODEBUILD_SRC_DIR/samples/
9+
10+
ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "ci/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
11+
12+
echo "Shadow test"
13+
python3 shadow.py --endpoint $ENDPOINT --key /tmp/privatekey.pem --cert /tmp/certificate.pem --thing_name CI_CodeBuild_Thing --is_ci true
14+
15+
popd

0 commit comments

Comments
 (0)