Doc update + linting + fix CI typo + fix port issue ECR

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville 2021-08-19 17:11:33 +02:00
parent f42a243692
commit 58209b87d1
11 changed files with 107 additions and 95 deletions

View File

@ -100,13 +100,14 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
services: services:
localstack: localstack:
image: localstack/localstack:latest image: localstack/localstack:0.12.16
env: env:
SERVICES: s3, ecr SERVICES: s3, ecr
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
ports: ports:
- 4566:4566 - 4566:4566
- 4571:4571 - 4571:4571
- 4510:4510
options: >- options: >-
--health-cmd "curl -f http://localhost:4566/health" --health-cmd "curl -f http://localhost:4566/health"
--health-start-period 5s --health-start-period 5s
@ -137,7 +138,7 @@ jobs:
env: env:
AWS_ACCESS_KEY_ID: test AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: eu-east-2 AWS_DEFAULT_REGION: us-east-2
run: | run: |
aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci
aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci

View File

@ -16,11 +16,12 @@ Re-usable aws-cli component
### aws.#CLI Inputs ### aws.#CLI Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*config.localMode* | `*null \| string` |AWS localstack mode |
### aws.#CLI Outputs ### aws.#CLI Outputs
@ -32,11 +33,12 @@ AWS Config shared by all AWS packages
### aws.#Config Inputs ### aws.#Config Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*region* | `string` |AWS region | |*region* | `string` |AWS region |
|*accessKey* | `dagger.#Secret` |AWS access key | |*accessKey* | `dagger.#Secret` |AWS access key |
|*secretKey* | `dagger.#Secret` |AWS secret key | |*secretKey* | `dagger.#Secret` |AWS secret key |
|*localMode* | `*null \| string` |AWS localstack mode |
### aws.#Config Outputs ### aws.#Config Outputs

View File

@ -21,6 +21,7 @@ AWS CloudFormation Stack
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*config.localMode* | `*null \| string` |AWS localstack mode |
|*source* | `string` |Source is the Cloudformation template (JSON/YAML string) | |*source* | `string` |Source is the Cloudformation template (JSON/YAML string) |
|*stackName* | `string` |Stackname is the cloudformation stack | |*stackName* | `string` |Stackname is the cloudformation stack |
|*parameters* | `struct` |Stack parameters | |*parameters* | `struct` |Stack parameters |

View File

@ -16,14 +16,16 @@ Convert ECR credentials to Docker Login format
### ecr.#Credentials Inputs ### ecr.#Credentials Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*ctr.image.config.region* | `string` |AWS region | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*ctr.image.config.accessKey* | `dagger.#Secret` |AWS access key | |*ctr.image.config.region* | `string` |AWS region |
|*ctr.image.config.secretKey* | `dagger.#Secret` |AWS secret key | |*ctr.image.config.accessKey* | `dagger.#Secret` |AWS access key |
|*ctr.image.config.secretKey* | `dagger.#Secret` |AWS secret key |
|*ctr.image.config.localMode* | `*null \| string` |AWS localstack mode |
### ecr.#Credentials Outputs ### ecr.#Credentials Outputs

View File

@ -16,13 +16,14 @@ KubeConfig config outputs a valid kube-auth-config for kubectl client
### eks.#KubeConfig Inputs ### eks.#KubeConfig Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*clusterName* | `string` |EKS cluster name | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*version* | `*"v1.19.9" \| string` |Kubectl version | |*clusterName* | `string` |EKS cluster name |
|*version* | `*"v1.19.9" \| string` |Kubectl version |
### eks.#KubeConfig Outputs ### eks.#KubeConfig Outputs

View File

@ -16,12 +16,13 @@ Returns an unused rule priority (randomized in available range)
### elb.#RandomRulePriority Inputs ### elb.#RandomRulePriority Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*listenerArn* | `string` |ListenerArn | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*listenerArn* | `string` |ListenerArn |
### elb.#RandomRulePriority Outputs ### elb.#RandomRulePriority Outputs

View File

@ -16,15 +16,16 @@ Creates a new Database on an existing RDS Instance
### rds.#Database Inputs ### rds.#Database Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*name* | `string` |DB name | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*dbArn* | `string` |ARN of the database instance | |*name* | `string` |DB name |
|*secretArn* | `string` |ARN of the database secret (for connecting via rds api) | |*dbArn* | `string` |ARN of the database instance |
|*dbType* | `string` |Database type MySQL or PostgreSQL (Aurora Serverless only) | |*secretArn* | `string` |ARN of the database secret (for connecting via rds api) |
|*dbType* | `string` |Database type MySQL or PostgreSQL (Aurora Serverless only) |
### rds.#Database Outputs ### rds.#Database Outputs
@ -38,12 +39,13 @@ Fetches information on an existing RDS Instance
### rds.#Instance Inputs ### rds.#Instance Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*dbArn* | `string` |ARN of the database instance | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*dbArn* | `string` |ARN of the database instance |
### rds.#Instance Outputs ### rds.#Instance Outputs
@ -59,17 +61,18 @@ Creates a new user credentials on an existing RDS Instance
### rds.#User Inputs ### rds.#User Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*username* | `string` |Username | |*config.localMode* | `*null \| string` |AWS localstack mode |
|*password* | `string` |Password | |*username* | `string` |Username |
|*dbArn* | `string` |ARN of the database instance | |*password* | `string` |Password |
|*secretArn* | `string` |ARN of the database secret (for connecting via rds api) | |*dbArn* | `string` |ARN of the database instance |
|*grantDatabase* | `*"" \| string` |Name of the database to grants access to | |*secretArn* | `string` |ARN of the database secret (for connecting via rds api) |
|*dbType* | `string` |Database type MySQL or PostgreSQL (Aurora Serverless only) | |*grantDatabase* | `*"" \| string` |Name of the database to grants access to |
|*dbType* | `string` |Database type MySQL or PostgreSQL (Aurora Serverless only) |
### rds.#User Outputs ### rds.#User Outputs

View File

@ -21,6 +21,7 @@ S3 Bucket object(s) sync
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret key | |*config.secretKey* | `dagger.#Secret` |AWS secret key |
|*config.localMode* | `*null \| string` |AWS localstack mode |
|*source* | `dagger.#Artifact` |Source Artifact to upload to S3 | |*source* | `dagger.#Artifact` |Source Artifact to upload to S3 |
|*target* | `string` |Target S3 URL (eg. s3://\<bucket-name\>/\<path\>/\<sub-path\>) | |*target* | `string` |Target S3 URL (eg. s3://\<bucket-name\>/\<path\>/\<sub-path\>) |
|*delete* | `*false \| true` |Delete files that already exist on remote destination | |*delete* | `*false \| true` |Delete files that already exist on remote destination |

View File

@ -10,13 +10,13 @@ import (
// AWS Config shared by all AWS packages // AWS Config shared by all AWS packages
#Config: { #Config: {
// AWS region // AWS region
region: dagger.#Input & { string } region: dagger.#Input & {string}
// AWS access key // AWS access key
accessKey: dagger.#Input & { dagger.#Secret } accessKey: dagger.#Input & {dagger.#Secret}
// AWS secret key // AWS secret key
secretKey: dagger.#Input & { dagger.#Secret } secretKey: dagger.#Input & {dagger.#Secret}
// AWS localstack mode // AWS localstack mode
localMode: dagger.#Input & { string | *null } localMode: dagger.#Input & {string | *null}
} }
// Re-usable aws-cli component // Re-usable aws-cli component
@ -33,7 +33,7 @@ import (
"package": curl: true "package": curl: true
"package": "aws-cli": "=~1.18" "package": "aws-cli": "=~1.18"
if config.localMode != null { if config.localMode != null {
"package": "py3-pip": true package: "py3-pip": true
} }
} }
}, },
@ -46,36 +46,36 @@ import (
"pipefail", "pipefail",
"-c", "-c",
if config.localMode == null { if config.localMode == null {
#""" #"""
aws configure set aws_access_key_id "$(cat /run/secrets/access_key)" aws configure set aws_access_key_id "$(cat /run/secrets/access_key)"
aws configure set aws_secret_access_key "$(cat /run/secrets/secret_key)" aws configure set aws_secret_access_key "$(cat /run/secrets/secret_key)"
aws configure set default.region "$AWS_DEFAULT_REGION" aws configure set default.region "$AWS_DEFAULT_REGION"
aws configure set default.cli_pager "" aws configure set default.cli_pager ""
aws configure set default.output "json" aws configure set default.output "json"
"""#, """#
} },
if config.localMode != null { if config.localMode != null {
#""" #"""
# Download awscli v3 and override aws # Download awscli v3 and override aws
pip install awscli-local[v2] pip install awscli-local[v2]
mv /usr/bin/awslocal /usr/bin/aws mv /usr/bin/awslocal /usr/bin/aws
# Configure # Configure
mkdir -p ~/.aws/ mkdir -p ~/.aws/
# Set up ~/.aws/config # Set up ~/.aws/config
echo "[default]" > ~/.aws/config echo "[default]" > ~/.aws/config
echo "region = $AWS_DEFAULT_REGION" >> ~/.aws/config echo "region = $AWS_DEFAULT_REGION" >> ~/.aws/config
echo "cli_pager =" >> ~/.aws/config echo "cli_pager =" >> ~/.aws/config
echo "output = json" >> ~/.aws/config echo "output = json" >> ~/.aws/config
# Set up ~/.aws/credentials # Set up ~/.aws/credentials
echo "[default]" > ~/.aws/credentials echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = $(cat /run/secrets/access_key)" >> ~/.aws/credentials echo "aws_access_key_id = $(cat /run/secrets/access_key)" >> ~/.aws/credentials
echo "aws_secret_access_key = $(cat /run/secrets/secret_key)" >> ~/.aws/credentials echo "aws_secret_access_key = $(cat /run/secrets/secret_key)" >> ~/.aws/credentials
"""#, """#
} },
] ]
mount: "/run/secrets/access_key": secret: config.accessKey mount: "/run/secrets/access_key": secret: config.accessKey
mount: "/run/secrets/secret_key": secret: config.secretKey mount: "/run/secrets/secret_key": secret: config.secretKey

View File

@ -17,14 +17,14 @@ TestECR: {
seed: "" seed: ""
} }
repository: string repository: string
if localMode == null { if localMode == null {
repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci" repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci"
} }
if localMode != null { if localMode != null {
repository: "localhost:4514/dagger-ci" repository: "localhost:4510/dagger-ci"
} }
tag: "test-ecr-\(suffix.out)" tag: "test-ecr-\(suffix.out)"
creds: #Credentials & { creds: #Credentials & {
config: TestConfig.awsConfig config: TestConfig.awsConfig

View File

@ -58,9 +58,9 @@ copy_to_sandbox() {
cp -a "$source_package" "$target_package" cp -a "$source_package" "$target_package"
fi fi
} }
# Check if there is a local kubernetes cluster. # Check if there is a localstack instance.
# #
# This is need to do kubernetes test in the CI. # This is needed to do docs test in the CI.
skip_unless_local_localstack() { skip_unless_local_localstack() {
if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ]; then if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ]; then
echo "Localstack available" echo "Localstack available"