I’m trying to store value in parameter store and to define TTL (Time To Live) for this value using C#, .NET with PutParameterRequest
.
How should I do it ?
This is how I’m saving the parameter for now with no expiration date:
var parametersStoreRequest = new PutParameterRequest()
{
Name = "Miao",
Value = "MiaoChech",
Type = ParameterType.String,
}
try {
var parametersStoreResponse = await parameterStoreClient.PutParameterAsync(parametersStoreRequest);
}
2
Answers
Solved ! Thank you @Arpit Jain for your answer :)
this is the correct format for PutParameterRequest in .net c#
You can use Parameter policies to assign specific criteria to a parameter such as an expiration date or time to live. Parameter Store allows the following types of policies:
Expiration
,ExpirationNotification
, andNoChangeNotification
.The following example shows the request syntax for a PutParameter API request that assigns
Expiration
to a newSecureString
parameter namedPassword
.So you need to pass the
Policies
values as a string with One or more policies to apply to a parameter inPutParameterRequest
.I am not familiar with the .Net but I hope this will help you to implement your requirement.
Note: The
Expiration
policy deletes the parameter. You can specify a specific date and time by using either theISO_INSTANT
format or theISO_OFFSET_DATE_TIME
format.The above example uses the
ISO_INSTANT
format. You can also specify a date and time by using theISO_OFFSET_DATE_TIME
format. Here is an example:2019-11-01T22:13:48.87+10:30:00
.Reference: PutParameter