-
Notifications
You must be signed in to change notification settings - Fork 824
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
Expose Custom Resources Outputs to aws-exports.js and other resources #11113
Comments
Caveat: I may be willing to implement this, but a pointer to the general area where this is implemented in the repository would help save a lot of time. |
Hey @convexset 👋 thanks for raising this! This feels similar to #9087, and I think it would be great to co-opt this issue as a feature request for general exposure of custom resource outputs, both to the |
Related certainly, but quite different. I’ve not actually solved that other problem in a manner that is as clean as this. (Record as a JSON field in a DDB configuration table that is read once on Lambda instantiation or when needed.) |
… a full solution would probably have a config file for determining which specific outputs can be exposed in |
Another thing I do is to link this to an AWS Chalice API: const CHALICE_PATH = '../backend'; console.log();
console.log(`EXPOSING CHALICE OUTPUTS in ${AWS_EXPORTS_PATH}`);
console.log(` - env: ${data.env}`)
try {
const chaliceDeploymentsPath = `${CHALICE_PATH}/.chalice/deployed`;
const files = fs.readdirSync(chaliceDeploymentsPath);
const filename = `${data.env}.json`;
if (!files.includes(filename)) {
throw new Error('deployment-record-not-found');
}
const chaliceDeploymentData = JSON.parse(fs.readFileSync(`${chaliceDeploymentsPath}/${filename}`, {
encoding: 'utf8'
}));
const chaliceAPIResources = chaliceDeploymentData.resources.filter(r => r.resource_type.endsWith('_api'))
if (chaliceAPIResources.length === 0) {
throw new Error('no-api-resources-available');
}
data.awsExports.aws_chalice_api_resources = {}
chaliceAPIResources.forEach(r => {
console.log(` - ${r.resource_type}`)
data.awsExports.aws_chalice_api_resources[r.resource_type] = r;
})
} catch (e) {
console.log(` - Unable to expose Chalice API outputs (${e.message})`)
}
console.log(); Which adds a section like this to {
...
"aws_chalice_api_resources": {
"rest_api": {
"name": "rest_api",
"resource_type": "rest_api",
"rest_api_id": "api123",
"rest_api_url": "https://api123.execute-api.ap-southeast-1.amazonaws.com/api-dev/"
},
"websocket_api": {
"name": "websocket_api",
"resource_type": "websocket_api",
"websocket_api_url": "wss://api789.execute-api.ap-southeast-1.amazonaws.com/api-dev/",
"websocket_api_id": "api789"
}
}
} |
+1 |
Is this feature request related to a new or existing Amplify category?
New category
Is this related to another service?
No response
Describe the feature you'd like to request
I'd like to reprise the request of #8886 but to caveat that it be without requiring the use of hooks.
Describe the solution you'd like
Refer to #8886 for an option, but here is part of what I have done:
The idea being that this could be easily rolled into
amplify push
.My on-machine deployment flow includes:
Here is an abbreviated version, which looks like
command-hooks
, but is not it:What it adds is the CFN outputs to
aws-exports.js
, with the end of the file now looking like:... which comes from a two of the same template that each containing just a Lambda role with overly broad privileges.
Describe alternatives you've considered
The above was my alternative, because
command-hooks
don't work in a console environment.Additional context
See #8886
Is this something that you'd be interested in working on?
Would this feature include a breaking change?
The text was updated successfully, but these errors were encountered: