Restoring API Gateway Resource from previous Deploy - aws-api-gateway

/r1
|- POST <-- accidentally deleted, want to restore
|- GET <-- new method, will remove the POST from the previous deploy
One of the methods in one of our resources has been deleted. The resource is of course still in the most recent deploy, and we want to restore it so we can add, say, a GET method to the same resource.
If we just add the new GET and deploy, the POST will be removed. Is there no way to save and restore an API?

2017- You can now export a stage as Swagger + API Gateway Extensions (Stages > [your stage] > Export > Swagger + API Gateway Extensions)and import it through Actions > Import API

You can easily restore your AWS API Gateway from a previous deployment. Go to API Gateway and select your API. Then select Stages. Pick a stage that has the last version of your deployment that you want to restore. Select it and click the Export tab, and export the JSON + Swagger file. Then select the Resources tab and under actions click Import. Once you import your swagger file, your API Gateway resources will be restored to the version that was deployed to that aforementioned Stage. I hope this helps.

Unfortunately this is not possible. You may want to manage your API moving forward using a Swagger or RAML definition and using the API import tool. Doing so will allow you to treat your API definition like source code, with tracking and ability to revert changes.

We can restore the previous state of the API gateway by changing deployment. If any resource is deleted then we can't restore that resource under API gateway Resources. but we can restore the previous deployment state and Also, we can export the restored deployment state using the Export option in Stages. You can see in the image that we can restore by choosing deployment and click on Change Deployment.

You can also try to use the CLI tool to retrieve configuration details for your deployed API (Get-Deployment CLI).
aws apigateway get-deployment --rest-api-id "value" --deployment-id "value"
The output contains a field "apiSummary" which will show you some details about the api configuration.
Best,
Jurgen

Related

Azure Logic App custom connector SOAP endpoint using WSDL

I am using a Logic App for which I need to create a custom connector. This connector depends on a web service, for which I am trying to add using wsdl definition.
Now If I provide the url, it needs authentication, which I am not able to provide via this UI. I can see the parameters can be provided while using it in the logic app. However it fails to pull the services and hence not creating the definition for the connector
I tried downloading the wsdl and adding here as a file, but the schema have xs import tags, because of which its failing again. And as per this answer, I can not replace it with actual schema.
<xs:import namespace="http://some.name/" schemaLocation="./path/to/it.xsd"/>
Is there a way that I do not need to provide the custom connector definition manually and make it work using wsdl, as it contains a lot of endpoints and it would be too much to add all actions and triggers manually. Plus it would be also reference for me if needed in future for such scenario
You may try this if the services are accessible over the internet, then you call service endpoint over HTTP or HTTPS from azure logic apps. This article will help you with details steps to be followed: https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http
If it is not accessible over the internet then this article will help with step by step process: https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-gateway-connection
Before you can access data sources on premises from your logic apps, you need to create an Azure resource after you install the on-premises data gateway on a local computer. Your logic apps then use this Azure gateway resource in the triggers and actions provided by the on-premises connectors that are available for Azure Logic Apps.
Also check this

Serverless Framework - Get API Gateway URL for use in tests

I'm using the Serverless framework, and I want to be able to reference my API Gateway URL in my acceptance tests.
My test environment is regularly destroyed and then recreated, so hardcoding a URL into the tests is not possible.
I can see there are ways to reference API Gateway as an AWS environment variable, but this doesnt help me to locally get the URL for my tests.
I was hoping that the cloudformation output would be referenced in the .serverless package, and accessible via json, but this doesnt seem to be the case.
Any idea how I can reference the API Gateway URL in my acceptance test files?
NOTE: These tests need to be run on AWS, not using a local server to mimic API Gateway
The serverless-plugin-test-helper plugin can help here. It will generate a YAML file containing all of the outputs of your stack. This includes a couple of standard ones - the S3 bucket that was used (ServerlessDeploymentBucketName) and the base service endpoint (ServiceEndpoint).
If you are using Node and have your tests in the same directory as the stack being tested then there's also a module to read this file. Otherwise, it's just standard YAML and you can use whatever tools are convenient.
Consider adding an APIGateway custom domain for your API. You can then use a known DNS name for your acceptance tests.
You will need to add an ApiGateway base path mapping, apigateway domain name, and a route53 recordset to the resources section of your serverless.yml.

How to get a foundary service whitelist IPs

We have a GUI that manages Cloud Foundry, and there's a link that show an instance with IP white list external dependency (quite large) How can I easily re-create this config as JSON, and recreate to diff Foundry env ?
It's not entirely clear what is being presented in your GUI but it sounds like it might be the application security groups. You might try running cf security-groups or cf security-group <name> to see if this information matches up with what's displayed in the GUI.
If that's what you want, you can use the following API calls to obtain the JSON data & recreate it in another environment.
1.) List all the security groups: http://apidocs.cloudfoundry.org/1.40.0/security_groups/list_all_security_groups.html
2.) List security groups applied to all applications: http://apidocs.cloudfoundry.org/1.40.0/security_group_running_defaults/return_the_security_groups_used_for_running_apps.html
3.) List security groups applied to all staging containers: http://apidocs.cloudfoundry.org/1.40.0/security_group_staging_defaults/return_the_security_groups_used_for_staging.html
4.) Retrieve a particular security group: http://apidocs.cloudfoundry.org/1.40.0/security_groups/retrieve_a_particular_security_group.html
And you can find more details about the API calls here: http://apidocs.cloudfoundry.org/
You can also run the cf cli commands above with the -v flag to show the HTTP requests being made by the CLI to obtain the information that's displayed.
Hope that helps!

Change service fabric config in live environment

I have configured my service fabric services to use Azure Key Vault for configuration. If, after the app is deployed, I change the config in Key Vault, how do I then restart the affected service so it can pick up the new config value?
Or is there another way altogether?
The best way to handle configuration on SF is use your application parameters file for this, if you use a continuous deployment pipeline like VSTS, you could use release variables to set these values for you and deploy a new version of your configuration file and let SF do the rest.
But in case you still need to use Key vault:
if you are using asp.net core, Using Azure Key Vault to store secrets are like loading configuration files, the values are cached until you reload it.
You can use the IConfigurationRoot.Reload() to reload the secrets from your key vault new values. Check it Here
The trick now is to make it automatically you have to:
Enable Key Vault Logging to track the changes, this will emit logs once you update the key vault. check it here and here .
And then:
Create an endpoint in your API to be called and refresh the secrets. Make it secure to avoid abuse.
Create an Azure function to process these logs and trigger the endpoint
Or:
Create a message queue to receive the command and the system read the message to refresh the settings
Or:
Make a timer to refresh on specific periods(I would not recommended this approach because you might end up with outdated config, but it is easy and useful for quick test scenarios, not production)
Or if you prefer more custom designed solution, you could create your own ConfigurationProvider based on KeyVault and do the cache logic according to your app architecture and you don't have to bother with the rest. Please refer to the Asp.Net source here for this.
The documented way to provide configuration to your services is by using the 'configuration' part of your application package.
As this is versioned, it can be upgraded, without requiring your services to be upgraded or even be restarted.
More info here and here.

How to rename an AWS API Gateway API instance?

In AWS API Gateway, is it possible to rename an API instance somehow?
I don't see the option on the UI, but maybe it's possible by using some API call.
Yes it's available in the API or CLI.
In the API you use a PATCH request on the 'name' field. http://docs.aws.amazon.com/apigateway/api-reference/resource/rest-api/
In the CLI, see docs http://docs.aws.amazon.com/cli/latest/reference/apigateway/update-rest-api.html
The PATCH op is 'replace' and the path would be '/name'
Edit: Thanks #Canotto90 for the example
aws apigateway update-rest-api --rest-api-id IDOfTheAPIThatNeedsTobeUpdated --patch-operations op=replace,path=/name,value=NewName
Here is how you can get the list of APIs and their IDs:
aws apigateway get-rest-apis
Use the Id to update name of API as mentioned by Canotto90 above:
aws apigateway update-rest-api --rest-api-id IDOfTheAPIThatNeedsTobeUpdated --patch-operations op=replace,path=/name,value=NewName
It turns out, there is now a way to rename the API!
Under the Amazon API Gateway service, select APIs. You will see the list of your APIs.
Now, click the little cog wheel in the top right corner of the API that you wish to rename...
Simply change the name, hit save, and you're good!
From https://console.aws.amazon.com/apigateway -> Select API by Name -> Settings -> General Settings -> Name
I know this is an old question, but people may still need an answer as I just did.
Amazon's AWS UI isn't always clear. There is no "Rename" function to change the name of an existing API. However, it can be done by cloning your existing API.
To rename your API, click the "Create API" button and select "Clone from existing API". This will allow you to give it a new name.
The latest version of the console allows you to edit the name via the API settings: see where in console here