Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/deploy-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ on:
type: string
description: Suffix to be appended to the layer name (default empty)
default: ""
description:
type: string
description: Optional description to add to the layer (default empty)
default: ""

jobs:
prepare-artifact:
Expand Down Expand Up @@ -122,7 +126,8 @@ jobs:
--layer-name "Datadog-Extension" \
--layer-suffix "${{ inputs.layerSuffix }}" \
--region ${{ github.event.inputs.region }} \
--key ${{ secrets.GH_ACTION_PUBLISHER_AEM_KEY }}
--key ${{ secrets.GH_ACTION_PUBLISHER_AEM_KEY }} \
--description "${{ inputs.description }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you the GitHub action when description is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to test this actually! is there a good way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write a integration test or manually trigger the workflow locally using https://cli.github.com/manual/gh_workflow_run


deploy-artifact:
if: ${{ github.event.inputs.region == 'all' }}
Expand Down Expand Up @@ -164,4 +169,5 @@ jobs:
--layer-name "Datadog-Extension" \
--layer-suffix "${{ inputs.layerSuffix }}" \
--region ${{ matrix.aws_region }} \
--key ${{ secrets.GH_ACTION_PUBLISHER_AEM_KEY }}
--key ${{ secrets.GH_ACTION_PUBLISHER_AEM_KEY }} \
--description "${{ inputs.description }}"
Binary file modified build-tools/bin/build_tools
Binary file not shown.
2 changes: 1 addition & 1 deletion build-tools/src/commands/auth_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct AuthOptions {
key: String,
}

pub async fn auth(args: &AuthOptions) -> Result<()> {
pub async fn auth(args: AuthOptions) -> Result<()> {
// set a random AWS_REGION as sts in region-agnostic
std::env::set_var("AWS_REGION", "us-east-1");

Expand Down
4 changes: 2 additions & 2 deletions build-tools/src/commands/build_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub struct BuildOptions {
docker_path: String,
}

pub fn build(args: &BuildOptions) -> Result<()> {
pub fn build(args: BuildOptions) -> Result<()> {
match args.cloudrun {
true => build_cloud_run(),
false => build_extension("cmd/serverless", args),
false => build_extension("cmd/serverless", &args),
}
}

Expand Down
5 changes: 4 additions & 1 deletion build-tools/src/commands/deploy_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ pub struct DeployOptions {
key: Option<String>,
#[structopt(long, default_value = "sa-east-1")]
region: String,
#[structopt(long)]
description: String,
}

pub async fn deploy(args: &DeployOptions) -> Result<()> {
pub async fn deploy(args: DeployOptions) -> Result<()> {
let config = build_config(&args.key, &args.region).await;
let lambda_client = lambda::Client::new(&config);

Expand All @@ -39,6 +41,7 @@ pub async fn deploy(args: &DeployOptions) -> Result<()> {
builder
.set_layer_name(Some(layer_name))
.set_content(Some(content.set_zip_file(Some(lambda_blob)).build()))
.set_description(Some(args.description))
.send()
.await
.expect("error while publishing the layer");
Expand Down
6 changes: 3 additions & 3 deletions build-tools/src/commands/deploy_function_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ pub struct DeployFunctionOptions {
should_invoke: bool,
}

pub async fn deploy_function(args: &DeployFunctionOptions) -> Result<()> {
pub async fn deploy_function(args: DeployFunctionOptions) -> Result<()> {
let api_key = std::env::var("DD_API_KEY").expect("could not find DD_API_KEY env");
std::env::set_var("AWS_REGION", &args.region);
let config = aws_config::load_from_env().await;
let lambda_client = lambda::Client::new(&config);
let layer_arn = get_latest_arn(&lambda_client, &args.layer_name).await?;
let deployed_arn = create_function(&lambda_client, args, layer_arn, api_key).await?;
let deployed_arn = create_function(&lambda_client, &args, layer_arn, api_key).await?;
if args.should_invoke {
thread::sleep(Duration::from_secs(15));
let invoke_args = InvokeFunctionOptions {
Expand All @@ -83,7 +83,7 @@ pub async fn deploy_function(args: &DeployFunctionOptions) -> Result<()> {
nb: 5, // to make sure enhanced metrics are flushed
remove_after: true,
};
invoke_function_command::invoke_function(&invoke_args).await?;
invoke_function_command::invoke_function(invoke_args).await?;
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion build-tools/src/commands/invoke_function_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct InvokeFunctionOptions {
pub remove_after: bool,
}

pub async fn invoke_function(args: &InvokeFunctionOptions) -> Result<()> {
pub async fn invoke_function(args: InvokeFunctionOptions) -> Result<()> {
std::env::set_var("AWS_REGION", &args.region);
let config = aws_config::load_from_env().await;
let lambda_client = lambda::Client::new(&config);
Expand Down
2 changes: 1 addition & 1 deletion build-tools/src/commands/list_region_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ListRegionOptions {
key: Option<String>,
}

pub async fn list_region(args: &ListRegionOptions) -> Result<()> {
pub async fn list_region(args: ListRegionOptions) -> Result<()> {
// set a random AWS_REGION as ec2:DescribeRgions in region-agnostic
let config = build_config(&args.key, "us-east-1").await;
let ec2_client = ec2::Client::new(&config);
Expand Down
6 changes: 3 additions & 3 deletions build-tools/src/commands/sign_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ pub struct SignOptions {
key: Option<String>,
}

pub async fn sign(args: &SignOptions) -> Result<()> {
pub async fn sign(args: SignOptions) -> Result<()> {
let config = build_config(&args.key, "sa-east-1").await; // TODO fixeme when ready for production
let s3_client = s3::Client::new(&config);
let signer_client = signer::Client::new(&config);
let key = build_s3_key();
upload_object(args, &key, &s3_client).await?;
upload_object(&args, &key, &s3_client).await?;
let job_id = sign_object(&key, &signer_client).await?;
verify(&job_id, &signer_client).await?;
download_object(args, &job_id, &s3_client).await?;
download_object(&args, &job_id, &s3_client).await?;
delete_object(&job_id, &s3_client).await?;
delete_object(&key, &s3_client).await?;
Ok(())
Expand Down
14 changes: 7 additions & 7 deletions build-tools/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ struct BuildTools {
async fn main() -> Result<()> {
let args = BuildTools::from_args();
match args.cmd {
SubCommand::Auth(opt) => auth(&opt).await,
SubCommand::Build(opt) => build(&opt),
SubCommand::Deploy(opt) => deploy(&opt).await,
SubCommand::Sign(opt) => sign(&opt).await,
SubCommand::ListRegion(opt) => list_region(&opt).await,
SubCommand::DeployLambdaFunction(opt) => deploy_function(&opt).await,
SubCommand::InvokeLambdaFunction(opt) => invoke_function(&opt).await,
SubCommand::Auth(opt) => auth(opt).await,
SubCommand::Build(opt) => build(opt),
SubCommand::Deploy(opt) => deploy(opt).await,
SubCommand::Sign(opt) => sign(opt).await,
SubCommand::ListRegion(opt) => list_region(opt).await,
SubCommand::DeployLambdaFunction(opt) => deploy_function(opt).await,
SubCommand::InvokeLambdaFunction(opt) => invoke_function(opt).await,
}
}