Back to Infisical

Create

docs/api-reference/endpoints/secret-rotations/cloudflare-r2-access-key/create.mdx

0.162.164.5 KB
Original Source
<Note> Check out the configuration docs for [Cloudflare R2 Access Key Rotations](/documentation/platform/secret-rotation/cloudflare-r2-access-key) to learn how to obtain the required parameters. </Note>

Creates a Cloudflare R2 Access Key secret rotation. Infisical will create and rotate the underlying Cloudflare API token via your Cloudflare connection, derive the S3-compatible access key from it, and write the credentials to the specified secret path.

Request body

FieldTypeRequiredDescription
namestringYesA unique name for the rotation (max 100 characters).
projectIdstring (UUID)YesThe project ID.
connectionIdstring (UUID)YesID of the Cloudflare app connection.
environmentstringYesEnvironment slug (e.g. dev, prod).
secretPathstringYesPath where the generated access key secrets will be stored.
isAutoRotationEnabledbooleanNoWhether to rotate automatically on the schedule. Defaults to true.
rotationIntervalnumberYesDays between rotations (minimum 1).
rotateAtUtcobjectNoTime of day (UTC) to run rotation: { "hours", "minutes" }. Defaults to { "hours": 0, "minutes": 0 }.
parameters.namestringYesThe name for the generated Cloudflare API token that backs the access key (max 100 characters). A timestamp is appended to each generated token.
parameters.bucketsarrayYesThe R2 buckets the generated access key is scoped to. At least one bucket is required, and each entry must be unique.
parameters.buckets[].namestringYesThe bucket's name, exactly as it appears in Cloudflare.
parameters.buckets[].jurisdictionstringNoThe bucket's storage jurisdiction: "default", "eu", or "fedramp". Defaults to "default".
parameters.accessLevelstringYesWhat the generated key can do on the selected buckets: "object-read" (get and list) or "object-read-write" (also put and delete).
parameters.allowedIpsstring[]NoThe IP addresses or CIDR blocks the generated access key is restricted to.
parameters.disallowedIpsstring[]NoThe IP addresses or CIDR blocks the generated access key is denied from.
secretsMapping.accessKeyIdstringYesSecret key name to store the generated access key ID (e.g. CLOUDFLARE_R2_ACCESS_KEY_ID).
secretsMapping.secretAccessKeystringYesSecret key name to store the generated secret access key (e.g. CLOUDFLARE_R2_SECRET_ACCESS_KEY).
descriptionstringNoOptional description.

Sample request

bash
curl --request POST \
  --url https://us.infisical.com/api/v2/secret-rotations/cloudflare-r2-access-key \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>' \
  --data '{
    "name": "my-r2-access-key-rotation",
    "projectId": "<project-id>",
    "description": "Cloudflare R2 access key rotation",
    "connectionId": "<cloudflare-connection-id>",
    "environment": "dev",
    "secretPath": "/",
    "isAutoRotationEnabled": true,
    "rotationInterval": 30,
    "rotateAtUtc": { "hours": 0, "minutes": 0 },
    "parameters": {
      "name": "infisical-r2-access-key",
      "buckets": [
        { "name": "my-bucket", "jurisdiction": "default" },
        { "name": "my-eu-bucket", "jurisdiction": "eu" }
      ],
      "accessLevel": "object-read",
      "allowedIps": ["203.0.113.0/24"]
    },
    "secretsMapping": {
      "accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
      "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
    }
  }'

Sample response

json
{
  "secretRotation": {
    "id": "<rotation-id>",
    "name": "my-r2-access-key-rotation",
    "description": "Cloudflare R2 access key rotation",
    "secretsMapping": {
      "accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
      "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
    },
    "isAutoRotationEnabled": true,
    "activeIndex": 0,
    "connectionId": "<cloudflare-connection-id>",
    "rotationInterval": 30,
    "rotateAtUtc": { "hours": 0, "minutes": 0 },
    "type": "cloudflare-r2-access-key",
    "parameters": {
      "name": "infisical-r2-access-key",
      "buckets": [
        { "name": "my-bucket", "jurisdiction": "default" },
        { "name": "my-eu-bucket", "jurisdiction": "eu" }
      ],
      "accessLevel": "object-read",
      "allowedIps": ["203.0.113.0/24"]
    }
  }
}