Environment Specific Patches?
Not sure if this is a feature request or just a question, but I'm trying to figure out how to implement different patches per environment or at least set parameters/variables per environment?
For example, if I have a staging and production environment how can I add this patch such that it doesn't get added to both load balancers or at least has slightly different values for each environment?
- op: add
path: /Resources/HTTPSListenerRuleRedirect
value:
Metadata:
'aws:copilot:description': 'An HTTPS listener redirect rule'
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- Type: redirect
RedirectConfig:
Protocol: HTTPS
Port: '443'
Host: 'production.com'
Path: '/foo'
Query: '#{query}'
StatusCode: HTTP_301
Conditions:
- Field: host-header
HostHeaderConfig:
Values:
- production.org
- Field: path-pattern
PathPatternConfig:
Values:
- /
Priority: 40000
ListenerArn: !GetAtt EnvControllerAction.HTTPSListenerArn
Relevant gitter convo: https://matrix.to/#/!QdxoBcgpJveoAoIPCc:gitter.im/$mrqCm6roJzNE2AGhtgilJA5S-0ytAQrUZXUe_fOJZJA?via=gitter.im&via=matrix.org&via=matrix.martinides.de
Hey @ssyberg! You could try using Conditions like in this example for addons: https://github.com/aws/copilot-cli/issues/4229. You can use patches to create conditions for each environment, and then add that Condition to the resources you want to conditionally create for each specific environment.
Hey @ssyberg! You could try using
Conditionslike in this example for addons: #4229. You can use patches to create conditions for each environment, and then add thatConditionto the resources you want to conditionally create for each specific environment.
Ooh yes that seems like it could work, ty!
This issue is stale because it has been open 60 days with no response activity. Remove the stale label, add a comment, or this will be closed in 14 days.
I thought I understood what to do here but I think it would be helpful to 1. get an example patch that has a condition and 2. ideally get an answer on if you have have multiple patch files per service, otherwise you'd need to include them all in a single file which seems messy?
Hi, @ssyberg!
Here is an example patch that changes an existing Condition: https://github.com/aws/copilot-cli/issues/5680#issuecomment-1984790251 and here is one that adds a Condition: https://github.com/aws/copilot-cli/issues/5387#issue-1943249493
And in answer to your other question, no, you cannot have multiple patch files
Thanks @huanjani though I think I don't know CFN well enough to totally understand this. Can you tell me exactly the steps I would take here to set up one set of ALB rules for staging and another set for production?
Hi @huanjani just wanted to bump this, I just had an unfortunate incident while making changes to my staging tasks, since the cfn is not environment specific it ended up messing up production! If there's an easy way to add conditionals to break these out it would be most appreciated!
This issue is stale because it has been open 60 days with no response activity. Remove the stale label, add a comment, or this will be closed in 14 days.
This issue is closed due to inactivity. Feel free to reopen the issue if you have any further questions!