Expose the HTTP URL as an APIGateway Stage output property
Adds two output properties on APIGateway Stage resources. * `url` is the full URL to the root of the deployed stage. * `executionARN` is the arn needed to pass to Lambda to give the stage permission to invoke a Lambda handler.
This commit is contained in:
parent
9bd441be05
commit
2914505a08
4 changed files with 15 additions and 0 deletions
|
@ -48,4 +48,8 @@ type Stage struct {
|
|||
CreatedDate string `lumi:"createdDate,out"`
|
||||
// The timestamp when the stage last updated.
|
||||
LastUpdatedDate string `lumi:"lastUpdatedDate,out"`
|
||||
// The URL to invoke the HTTP endpoint for this API stage.
|
||||
URL string `lumi:"url,out"`
|
||||
// The execution ARN needed to pass to Lambda to give this API stage permission.
|
||||
ExecutionARN string `lumi:"executionARN,out"`
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ export class Stage extends lumi.Resource implements StageArgs {
|
|||
public variables?: {[key: string]: string};
|
||||
public createdDate: string;
|
||||
public lastUpdatedDate: string;
|
||||
public url: string;
|
||||
public executionARN: string;
|
||||
|
||||
constructor(name: string, args: StageArgs) {
|
||||
super();
|
||||
|
|
|
@ -106,6 +106,9 @@ func (p *stageProvider) Get(ctx context.Context, id resource.ID) (*apigateway.St
|
|||
}
|
||||
variables := aws.StringValueMap(resp.Variables)
|
||||
|
||||
url := "https://" + restAPIID + ".execute-api." + p.ctx.Region() + ".amazonaws.com/" + stageName
|
||||
executionARN := "arn:aws:execute-api:" + p.ctx.Region() + ":" + p.ctx.AccountID() + ":" + restAPIID + "/" + stageName
|
||||
|
||||
return &apigateway.Stage{
|
||||
RestAPI: NewRestAPIID(p.ctx.Region(), restAPIID),
|
||||
Deployment: NewDeploymentID(p.ctx.Region(), restAPIID, aws.StringValue(resp.DeploymentId)),
|
||||
|
@ -116,6 +119,8 @@ func (p *stageProvider) Get(ctx context.Context, id resource.ID) (*apigateway.St
|
|||
Description: resp.Description,
|
||||
CreatedDate: resp.CreatedDate.String(),
|
||||
LastUpdatedDate: resp.LastUpdatedDate.String(),
|
||||
URL: url,
|
||||
ExecutionARN: executionARN,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,8 @@ type Stage struct {
|
|||
Variables *map[string]string `lumi:"variables,optional"`
|
||||
CreatedDate string `lumi:"createdDate,optional"`
|
||||
LastUpdatedDate string `lumi:"lastUpdatedDate,optional"`
|
||||
URL string `lumi:"url,optional"`
|
||||
ExecutionARN string `lumi:"executionARN,optional"`
|
||||
}
|
||||
|
||||
// Stage's properties have constants to make dealing with diffs and property bags easier.
|
||||
|
@ -206,6 +208,8 @@ const (
|
|||
Stage_Variables = "variables"
|
||||
Stage_CreatedDate = "createdDate"
|
||||
Stage_LastUpdatedDate = "lastUpdatedDate"
|
||||
Stage_URL = "url"
|
||||
Stage_ExecutionARN = "executionARN"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue