A place to share technical learnings, etc.
aws | jekyll | github | apigateway | serverless | ad | powershell | windows | webdev | nodejs | terraform | consul | nomad | jenkins | traefik | azuread | azure | nextjs |
AWS’ Application load balancer supports OIDC authentication, but I couldn’t find a single document that shows how to configure this to work with AzureAD auth.
We manage our AWS infrastructure with Terraform.
The biggest problem I had here was discovering the correct endpoints for the OIDC configuration. Eventually I found these are all available in the .well-known configuration, which should be available at: https://login.microsoftonline.com/YOUR_TENANT_ID/v2.0/.well-known/openid-configuration
Here’s the configuration for the ALB load balancer rule with AzureAD authentication. Substitute in your Tenant ID, Client ID, and Secret.
resource "aws_lb_listener_rule" "ALBTest" {
listener_arn = data.terraform_remote_state.ECS.outputs.aws_lb_listener_arn
action {
type = "authenticate-oidc"
authenticate_oidc {
authorization_endpoint = "https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/authorize"
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
issuer = "https://login.microsoftonline.com/YOUR_TENANT_ID/v2.0"
token_endpoint = "https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token"
user_info_endpoint = "https://graph.microsoft.com/oidc/userinfo"
}
}
action {
type = "forward"
target_group_arn = aws_lb_target_group.ALBTest.arn
}
condition {
field = "host-header"
values = ["myapp.mydomain.io"]
}
}