Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Proper background/detached mode. #20

Closed
skyzyx opened this issue Mar 10, 2021 · 2 comments
Closed

[Request] Proper background/detached mode. #20

skyzyx opened this issue Mar 10, 2021 · 2 comments

Comments

@skyzyx
Copy link

skyzyx commented Mar 10, 2021

By default, this tool runs in the foreground and prints data to stdout.

It would be nice to enable a proper background/detached mode, which:

  1. Runs in the background.
  2. When run in the background, it returns its PID.
  3. Implies the use of -output-file.
  4. Background mode would not write to stdout.

That would let me do something like this:

ACCOUNT_ID=$(aws sts get-caller-identity | jq -Mr '.AccountId')

IAMLIVE_PID=$(
    iamlive \
        --detached \
        --mode proxy \
        --output-file policy.json \
        --refresh-rate 1 \
        --sort-alphabetical \
        --bind-addr 127.0.0.1:10080 \
        --ca-bundle ~/.iamlive/ca.pem \
        --ca-key ~/.iamlive/ca.key \
        --account-id "$ACCOUNT_ID"
)

AWS_CSM_ENABLED=true
HTTP_PROXY=http://127.0.0.1:10080
HTTPS_PROXY=http://127.0.0.1:10080
AWS_CA_BUNDLE=~/.iamlive/ca.pem

terraform apply -auto-approve
terraform destroy -auto-approve

kill "$IAMLIVE_PID"

It also means that policy.json would need to be written even if a SIGKILL is received. (If there's a different signal that should be sent, documenting it would be valuable.)

iann0036 added a commit that referenced this issue Mar 12, 2021
@iann0036
Copy link
Owner

Implemented as --background, available in v0.19.

Will write and quit if receiving a SIGINT, SIGTERM (your example) or SIGQUIT.

Will write and continue running if receiving a SIGHUP.

@skyzyx
Copy link
Author

skyzyx commented Mar 14, 2021

👍🏻

@skyzyx skyzyx closed this as completed Mar 18, 2021
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

No branches or pull requests

2 participants