Skip to content

Implements universe/aws and universe/aws/cli - #1622

Merged
talentedmrjones merged 1 commit into
dagger:mainfrom
talentedmrjones:europa-universe-aws-cli
Feb 23, 2022
Merged

talentedmrjones merged 1 commit into
dagger:mainfrom
talentedmrjones:europa-universe-aws-cli

Conversation

@talentedmrjones

@talentedmrjones talentedmrjones commented Feb 15, 2022 •

Copy link
Copy Markdown

This implements the following in universe/aws and universe/aws/cli

  • aws.#Build provides a ready made docker.#Image with the CLI pre-installed to Amazon Linux 2 which avoids trust issues with installing glibc to Alpine from unknown parties
  • aws.#Container provides an environment pre-configured with credentials and an optional config file. This is meant to execute any command that uses an AWS SDK (not just CLI). Other packages under universe/aws will use this as a base primitive such as aws/cli and eventually aws/cloudformation and aws/s3. (This is generally not intended for direct use except in cases to support highly customized scripts that require the AWS SDK, but may prove very useful for teams migrating existing scripts to dagger.)
  • cli.#Command as a declarative wrapper to the aws CLI. By specifying the global options, service name, and sub-command, #Command will automatically format the correct shell syntax and execute via aws.#Container storing the output in /output.txt. Furthermore when setting unmarshal: true (default) this definition will automatically json.Unmarshal the result into a CUE struct that can be referenced by result.field where field was present in the JSON output.

To use:

getCallerIdentity: cli.#Command & {
  credentials: aws.#Credentials & {
    accessKeyId:     inputs.secrets.AWS_ACCESS_KEY_ID.contents
    secretAccessKey: inputs.secrets.AWS_SECRET_ACCESS_KEY.contents
  }
  options: region: "us-east-2"
  service: {
    name:    "sts"
    command: "get-caller-identity"
  }
}

verify: getCallerIdentity.result & {
  UserId:  !~"^$"
  Account: !~"^$"
  Arn:     !~"^$"
}

@talentedmrjones talentedmrjones changed the title Add universe/aws/cli [WIP] Add universe/aws/cli Feb 15, 2022
@talentedmrjones
talentedmrjones requested review from aluzzardi and jlongtine and removed request for aluzzardi February 15, 2022 23:07
@talentedmrjones
talentedmrjones force-pushed the europa-universe-aws-cli branch 2 times, most recently from 6e14228 to 2a4d1dc Compare February 21, 2022 17:53
@talentedmrjones talentedmrjones changed the title [WIP] Add universe/aws/cli Implementes universe/aws and universe/aws/cli Feb 21, 2022
@talentedmrjones talentedmrjones changed the title Implementes universe/aws and universe/aws/cli Implements universe/aws and universe/aws/cli Feb 21, 2022
@talentedmrjones
talentedmrjones force-pushed the europa-universe-aws-cli branch 2 times, most recently from c6d6a22 to e645057 Compare February 22, 2022 19:06
@talentedmrjones
talentedmrjones requested review from samalba and removed request for jlongtine February 23, 2022 17:21

@samalba samalba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall this is an impvrovement from what we had before. Although there is no active use case for aws yet, I would still merge this as we're gonna need it pretty soon. However I would not implement top-level aws packages until we get a higher user need.

Comment thread pkg/universe.dagger.io/aws/aws.cue Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: I usually use aliases for that (let DefaultCLIVersion = ""). Just a coding-style thing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm actually referencing this in the test via aws.#DefaultCliVersion that way we don't have to change it in 2 places.

Comment thread pkg/universe.dagger.io/aws/cli/cli.cue Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if at some point this gets challenging to maintain, I would not validate and just set a type string.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This can be automated actually

@talentedmrjones
talentedmrjones merged commit a4088fa into dagger:main Feb 23, 2022
@talentedmrjones
talentedmrjones deleted the europa-universe-aws-cli branch February 23, 2022 21:47
@shykes

shykes commented Mar 3, 2022

Copy link
Copy Markdown
Contributor

Would have loved to review this one FYI.

@shykes

shykes commented Mar 3, 2022

Copy link
Copy Markdown
Contributor

We had an ongoing review in another PR which I had outstanding comments on. Then PR got closed and I just realized by chance that this got opened separately and merged.

@shykes

shykes commented Mar 3, 2022

Copy link
Copy Markdown
Contributor

My concerns are mostly around enforcing consistent pattern around the use of docker.#Run, customization, naming of the definitions themselves, choice of workarounds for broken docker.#Build. In alpha.dagger.io we had very loose review and consistency requirements and the result was all over the place. It’s very hard to change APIs once people use them which compounds the problem.

Please please ping me for every universe PR, it’s not great to have an individual review bottleneck but it’s better than breaking every developer later or giving up on consistency altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants